You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/12/13 23:59:21 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers DOMParser.java DTDXSParserConfiguration.java SAXParser.java StandardParserConfiguration.java

elena       01/12/13 14:59:21

  Modified:    java/src/org/apache/xerces/parsers DOMParser.java
                        DTDXSParserConfiguration.java SAXParser.java
                        StandardParserConfiguration.java
  Log:
  Change the default parser configuration to StandardParserConfiguration.
  In standard config move the setup of the pipeline to parse(boolean) (the components of the pipeline will be reset there as well).
  Standard config will add XML schema Validator to the pipeline if schema validation feature is turned on.
  
  Revision  Changes    Path
  1.55      +4 -5      xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java
  
  Index: DOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- DOMParser.java	2001/11/16 14:22:59	1.54
  +++ DOMParser.java	2001/12/13 22:59:20	1.55
  @@ -87,11 +87,10 @@
    * parser with a document scanner, a dtd scanner, and a validator, as 
    * well as a grammar pool.
    *
  - * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: DOMParser.java,v 1.54 2001/11/16 14:22:59 neilg Exp $ 
  + * @version $Id: DOMParser.java,v 1.55 2001/12/13 22:59:20 elena Exp $ 
    */
   public class DOMParser
       extends AbstractDOMParser {
  @@ -104,7 +103,7 @@
        * Constructs a DOM parser using the dtd/xml schema parser configuration.
        */
       public DOMParser() {
  -        super(new DTDXSParserConfiguration());
  +        super(new StandardParserConfiguration());
       } // <init>
   
       /**
  @@ -118,7 +117,7 @@
        * Constructs a DOM parser using the specified symbol table.
        */
       public DOMParser(SymbolTable symbolTable) {
  -        super(new DTDXSParserConfiguration(symbolTable));
  +        super(new StandardParserConfiguration(symbolTable));
       } // <init>(SymbolTable)
   
   
  @@ -127,7 +126,7 @@
        * grammar pool.
        */
       public DOMParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  -        super(new DTDXSParserConfiguration(symbolTable, grammarPool));
  +        super(new StandardParserConfiguration(symbolTable, grammarPool));
       }
   
       //
  
  
  
  1.4       +1 -7      xml-xerces/java/src/org/apache/xerces/parsers/DTDXSParserConfiguration.java
  
  Index: DTDXSParserConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DTDXSParserConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DTDXSParserConfiguration.java	2001/11/02 01:26:45	1.3
  +++ DTDXSParserConfiguration.java	2001/12/13 22:59:20	1.4
  @@ -72,16 +72,10 @@
    * instance document against schema.
    * 
    * @author Sandy Gao, IBM
  - * @version $Id: DTDXSParserConfiguration.java,v 1.3 2001/11/02 01:26:45 andyc Exp $
  + * @version $Id: DTDXSParserConfiguration.java,v 1.4 2001/12/13 22:59:20 elena Exp $
    */
   public class DTDXSParserConfiguration extends StandardParserConfiguration {
   
  -    /** Property identifier: XML Schema validator. */
  -    protected static final String SCHEMA_VALIDATOR =
  -        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;
  -
  -    /** XML Schema Validator. */
  -    protected XMLSchemaValidator fSchemaValidator;
   
       //
       // Constructors
  
  
  
  1.26      +4 -5      xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java
  
  Index: SAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SAXParser.java	2001/10/25 14:19:46	1.25
  +++ SAXParser.java	2001/12/13 22:59:20	1.26
  @@ -66,11 +66,10 @@
    * parser with a document scanner, a dtd scanner, and a validator, as 
    * well as a grammar pool.
    *
  - * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: SAXParser.java,v 1.25 2001/10/25 14:19:46 elena Exp $ 
  + * @version $Id: SAXParser.java,v 1.26 2001/12/13 22:59:20 elena Exp $ 
    */
   public class SAXParser
       extends AbstractSAXParser {
  @@ -83,7 +82,7 @@
        * Constructs a SAX parser using the dtd/xml schema parser configuration.
        */
       public SAXParser() {
  -        super(new DTDXSParserConfiguration());
  +        super(new StandardParserConfiguration());
       } // <init>()
   
       /**
  @@ -97,7 +96,7 @@
        * Constructs a SAX parser using the specified symbol table.
        */
       public SAXParser(SymbolTable symbolTable) {
  -        super(new DTDXSParserConfiguration(symbolTable));
  +        super(new StandardParserConfiguration(symbolTable));
       } // <init>(SymbolTable)
   
       /**
  @@ -105,7 +104,7 @@
        * grammar pool.
        */
       public SAXParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  -        super(new DTDXSParserConfiguration(symbolTable, grammarPool));
  +        super(new StandardParserConfiguration(symbolTable, grammarPool));
       } // <init>(SymbolTable,GrammarPool)
   
   } // class SAXParser
  
  
  
  1.8       +81 -22    xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java
  
  Index: StandardParserConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StandardParserConfiguration.java	2001/10/25 20:36:05	1.7
  +++ StandardParserConfiguration.java	2001/12/13 22:59:21	1.8
  @@ -72,6 +72,9 @@
   import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactory;
   import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactoryImpl;
   import org.apache.xerces.impl.validation.GrammarPool;
  +
  +import org.apache.xerces.impl.xs.XSMessageFormatter;
  +import org.apache.xerces.impl.xs.XMLSchemaValidator;
   import org.apache.xerces.util.SymbolTable;
   import org.apache.xerces.xni.XMLLocator;
   import org.apache.xerces.xni.XNIException;
  @@ -118,7 +121,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: StandardParserConfiguration.java,v 1.7 2001/10/25 20:36:05 elena Exp $
  + * @version $Id: StandardParserConfiguration.java,v 1.8 2001/12/13 22:59:21 elena Exp $
    */
   public class StandardParserConfiguration
       extends BasicParserConfiguration 
  @@ -195,6 +198,11 @@
       protected static final String VALIDATION_MANAGER =
           Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
   
  +    /** Property identifier: XML Schema validator. */
  +    protected static final String SCHEMA_VALIDATOR =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;
  +
  +
       // debugging
   
       /** Set to true and recompile to print exception stack trace. */
  @@ -223,6 +231,9 @@
       /** Document scanner. */
       protected XMLDocumentScanner fScanner;
   
  +    /** Input Source */
  +    protected XMLInputSource fInputSource;
  +
       /** DTD scanner. */
       protected XMLDTDScanner fDTDScanner;
   
  @@ -232,6 +243,9 @@
       /** Namespace binder. */
       protected XMLNamespaceBinder fNamespaceBinder;
   
  +    /** XML Schema Validator. */
  +    protected XMLSchemaValidator fSchemaValidator;
  +
       protected ValidationManager fValidationManager;
       // state
   
  @@ -434,27 +448,14 @@
        */
       public void setInputSource(XMLInputSource inputSource)
           throws XMLConfigurationException, IOException {
  -
  -        try {
  -            reset();
  -            fScanner.setInputSource(inputSource);
  -        } 
  -        catch (XNIException ex) {
  -            if (PRINT_EXCEPTION_STACK_TRACE)
  -                ex.printStackTrace();
  -            throw ex;
  -        } 
  -        catch (IOException ex) {
  -            if (PRINT_EXCEPTION_STACK_TRACE)
  -                ex.printStackTrace();
  -            throw ex;
  -        } 
  -        catch (Exception ex) {
  -            if (PRINT_EXCEPTION_STACK_TRACE)
  -                ex.printStackTrace();
  -            throw new XNIException(ex);
  -        }
  +        
  +        // REVISIT: this method used to reset all the components and
  +        //          construct the pipeline. Now reset() is called
  +        //          in parse (boolean) just before we parse the document
  +        //          Should this method still throw exceptions..?
   
  +        fInputSource = inputSource;
  +        
       } // setInputSource(XMLInputSource)
   
       /**
  @@ -474,7 +475,32 @@
        * @see #setInputSource
        */
       public boolean parse(boolean complete) throws XNIException, IOException {
  -        
  +        //
  +        // reset and configure pipeline and set InputSource.
  +        if (fInputSource !=null) {
  +            try {
  +                // resets and sets the pipeline.
  +                reset();
  +                fScanner.setInputSource(fInputSource);
  +                fInputSource = null;
  +            } 
  +            catch (XNIException ex) {
  +                if (PRINT_EXCEPTION_STACK_TRACE)
  +                    ex.printStackTrace();
  +                throw ex;
  +            } 
  +            catch (IOException ex) {
  +                if (PRINT_EXCEPTION_STACK_TRACE)
  +                    ex.printStackTrace();
  +                throw ex;
  +            } 
  +            catch (Exception ex) {
  +                if (PRINT_EXCEPTION_STACK_TRACE)
  +                    ex.printStackTrace();
  +                throw new XNIException(ex);
  +            }
  +        }
  +
           try {
               return fScanner.scanDocument(complete);
           } 
  @@ -594,6 +620,34 @@
               }
           }
   
  +        if ( getFeature(Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE)) {
  +            // If schema validator was not in the pipeline insert it.
  +            if (fSchemaValidator == null) {
  +                fSchemaValidator = new XMLSchemaValidator(); 
  +            
  +                // add schema component
  +                fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator);
  +                addComponent(fSchemaValidator);
  +                 // add schema message formatter
  +                if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
  +                    XSMessageFormatter xmft = new XSMessageFormatter();
  +                    fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);
  +                }
  +
  +            }
  +            fNamespaceBinder.setDocumentHandler(fSchemaValidator);
  +            fSchemaValidator.setDocumentHandler(fDocumentHandler);
  +            
  +
  +            // REVISIT: we probably should not remove schema validator from the pipeline
  +            // if schema feature is off, since user might want to have some PSVI 
  +            // of the document.
  +            // On the other hand, if user constructed a parser with the default config,
  +            // turned schema on before first parse(), and then turned it off, is it possible
  +            // that user would assume that we will remove XML Schema validator?
  +        } 
  +
  +
       } // configurePipeline()
   
       // features and properties
  @@ -633,6 +687,11 @@
               //   on each document instance, automatically.
               //
               if (feature.equals(Constants.DYNAMIC_VALIDATION_FEATURE)) {
  +                return;
  +            }
  +
  +            // activate full schema checking
  +            if (feature.equals(Constants.SCHEMA_FULL_CHECKING)) {
                   return;
               }
               //
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org