commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/digester/src/java/org/apache/commons/digester Digester.java package.html
Date Tue, 06 Jan 2004 22:15:57 GMT
rdonkin     2004/01/06 14:15:57

  Modified:    digester/src/java/org/apache/commons/digester Digester.java
                        package.html
  Log:
  Parser guessing schema configuration setting code. Contributed by Jean-Francois Arcand.
  
  Revision  Changes    Path
  1.88      +20 -26    jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java
  
  Index: Digester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- Digester.java	2 Dec 2003 23:21:16 -0000	1.87
  +++ Digester.java	6 Jan 2004 22:15:57 -0000	1.88
  @@ -7,7 +7,7 @@
    * 
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -74,6 +74,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Properties;
   
   import javax.xml.parsers.ParserConfigurationException;
   import javax.xml.parsers.SAXParser;
  @@ -113,8 +114,8 @@
    * even from the same thread.</p>
    *
    * <p><strong>IMPLEMENTATION NOTE</strong> - A bug in Xerces 2.0.2 prevents
  - * the support of XML schema. You need Xerces 2.1 or JAXP 1.2.1 to make
  - * that class working with XML schema</p>
  + * the support of XML schema. You need Xerces 2.1/2.3 and up to make
  + * this class working with XML schema</p>
    *
    * @author Craig McClanahan
    * @author Scott Sanders
  @@ -224,19 +225,12 @@
        */
       protected SAXParserFactory factory = null;
   
  -
  -    /**
  -     * The JAXP 1.2 property required to set up the schema location.
  -     */
  -    private static final String JAXP_SCHEMA_SOURCE =
  -        "http://java.sun.com/xml/jaxp/properties/schemaSource";
  -
       /**
  -     * The JAXP 1.2 property to set up the schemaLanguage used.
  +     * @deprecated This is now managed by {@link ParserFeatureSetterFactory}
        */
       protected String JAXP_SCHEMA_LANGUAGE =
           "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  -
  +    
       
       /**
        * The Locator associated with our parser.
  @@ -706,21 +700,21 @@
   
           // Create a new parser
           try {
  -            parser = getFactory().newSAXParser();         
  +            if (validating) {
  +                Properties properties = new Properties();
  +                properties.put("SAXParserFactory", getFactory());
  +                if (schemaLocation != null) {
  +                    properties.put("schemaLocation", schemaLocation);
  +                    properties.put("schemaLanguage", schemaLanguage);
  +                }
  +                parser = ParserFeatureSetterFactory.newSAXParser(properties);         
     } else {
  +                parser = getFactory().newSAXParser();
  +            }
           } catch (Exception e) {
               log.error("Digester.getParser: ", e);
               return (null);
           }
   
  -        // Configure standard properties and return the new instance
  -        try {
  -            if (schemaLocation != null) {
  -                setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
  -                setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
  -            }
  -        } catch (Exception e) {
  -            log.warn("" + e);
  -        }
           return (parser);
   
       }
  
  
  
  1.24      +16 -0     jakarta-commons/digester/src/java/org/apache/commons/digester/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/package.html,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- package.html	28 Sep 2003 09:41:29 -0000	1.23
  +++ package.html	6 Jan 2004 22:15:57 -0000	1.24
  @@ -1006,6 +1006,22 @@
   This warning is harmless.</p>
   <p>
   </li>
  +<li></a><strong>Why Doesn't Schema Validation Work With Parser XXX Out
Of The Box?</strong>
  +<p>
  +Schema location and language settings are often need for validation using schemas.
  +Unfortunately, there isn't a single standard approach to how these properties are
  +configured on a parser.
  +Digester tries to guess the parser being used and configure it appropriately
  +but it's not infallible.
  +You might need to grab an instance, configure it and pass it to Digester.
  +</p>
  +<p>
  +If you want to support more than one parser in a portable manner, 
  +then you'll probably want to take a look at the 
  +<code>org.apache.commons.digester.parsers</code> package
  +and add a new class to support the particular parser that's causing problems.
  +</p>
  +</li>
   <li></a><strong>Where Can I Find Example Code?</strong>
   <a name="doc.FAQ.Examples">
   <p>Digester ships with a sample application: a mapping for the <em>Rich Site

  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message