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

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers AbstractDOMParser.java AbstractSAXParser.java DOMParser.java SAXParser.java XMLDocumentParser.java XMLParser.java

lehors      01/02/13 14:51:29

  Modified:    java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        AbstractDOMParser.java AbstractSAXParser.java
                        DOMParser.java SAXParser.java
                        XMLDocumentParser.java XMLParser.java
  Log:
  Components are no longer created from the Parser constructor. Instead they
  are created from an initialize method that is called before the first parse.
  In addition, the initialize method only creates components that are not
  already registered. This effectively allows an application to specify
  through the relevant properties any components it wants. For instance, one
  can do something like:
  
  SAXParser parser = new SAXParser();
  parser.setProperty(DOCUMENT_SCANNER, mydocscanner);
  ...
  parser.parse(arg);
  
  Also, the components are now stored in a Vector which is used to call
  reset(), setFeature(), and setProperty() on every component, directly from
  the base class. This saves us some code.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +7 -10     xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java
  
  Index: AbstractDOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractDOMParser.java	2001/02/13 19:04:57	1.1.2.1
  +++ AbstractDOMParser.java	2001/02/13 22:51:24	1.1.2.2
  @@ -91,7 +91,7 @@
    * @author Andy Clark, IBM
    *
    * 
  - * @version $Id: AbstractDOMParser.java,v 1.1.2.1 2001/02/13 19:04:57 lehors Exp $ */
  + * @version $Id: AbstractDOMParser.java,v 1.1.2.2 2001/02/13 22:51:24 lehors Exp $ */
   public abstract class AbstractDOMParser
       extends XMLDocumentParser {
   
  @@ -134,15 +134,6 @@
       protected AbstractDOMParser() {
       } // <init>()
   
  -    /**
  -     * 
  -     * 
  -     * @param symbolTable 
  -     */
  -    protected AbstractDOMParser(SymbolTable symbolTable) {
  -        super(symbolTable);
  -    } // <init>(SymbolTable)
  -
       //
       // Public methods
       //
  @@ -271,6 +262,8 @@
           fDocument = new DocumentImpl();
           fDocumentImpl = (DocumentImpl)fDocument;
           fCurrentNode = fDocument;
  +        // set DOM error checking off
  +        fDocumentImpl.setErrorChecking(false);
   
       } // startDocument()
   
  @@ -446,6 +439,10 @@
        */
       public void endDocument() throws SAXException {
   
  +        // set DOM error checking back on
  +        if (fDocumentImpl != null) {
  +            fDocumentImpl.setErrorChecking(true);
  +        }
           fInDocument = false;
           fCurrentNode = null;
   
  
  
  
  1.1.2.2   +1 -10     xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java
  
  Index: AbstractSAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractSAXParser.java	2001/02/13 19:04:57	1.1.2.1
  +++ AbstractSAXParser.java	2001/02/13 22:51:25	1.1.2.2
  @@ -88,7 +88,7 @@
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Andy Clark, IBM
    *
  - * @version $Id: AbstractSAXParser.java,v 1.1.2.1 2001/02/13 19:04:57 lehors Exp $ */
  + * @version $Id: AbstractSAXParser.java,v 1.1.2.2 2001/02/13 22:51:25 lehors Exp $ */
   public abstract class AbstractSAXParser
       extends XMLDocumentParser
       implements Parser, XMLReader // SAX1, SAX2
  @@ -127,15 +127,6 @@
       /** Default constructor. */
       protected AbstractSAXParser() {
       } // <init>()
  -
  -    /**
  -     * Constructs a SAX parser specifying the symbol table.
  -     * 
  -     * @param symbolTable The symbol table.
  -     */
  -    protected AbstractSAXParser(SymbolTable symbolTable) {
  -        super(symbolTable);
  -    } // <init>(SymbolTable)
   
       //
       // XMLDocumentHandler methods
  
  
  
  1.19.2.12 +46 -119   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.19.2.11
  retrieving revision 1.19.2.12
  diff -u -r1.19.2.11 -r1.19.2.12
  --- DOMParser.java	2001/02/13 19:04:57	1.19.2.11
  +++ DOMParser.java	2001/02/13 22:51:25	1.19.2.12
  @@ -85,7 +85,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: DOMParser.java,v 1.19.2.11 2001/02/13 19:04:57 lehors Exp $ */
  + * @version $Id: DOMParser.java,v 1.19.2.12 2001/02/13 22:51:25 lehors Exp $ */
   public class DOMParser
       extends AbstractDOMParser {
   
  @@ -126,32 +126,20 @@
       //
   
       /**
  -     * Constructs a document parser using the default symbol table
  -     * and grammar pool.
  +     * Constructs a DOM parser.
        */
       public DOMParser() {
  -        this(new SymbolTable(), new GrammarPool());
  -    } // <init>()
  +    } // <init>
   
  -    /** 
  -     * Constructs a document parser using the specified symbol table
  -     * and a default grammar pool.
  -     */
  -    public DOMParser(SymbolTable symbolTable) {
  -        this(symbolTable, new GrammarPool());
  -    } // <init>(SymbolTable)
  -
       /**
  -     * Constructor allowing to specify the symbol table and grammar pool 
  -     * to use. The symbol table and grammar pool are specified together
  -     * because the grammars contained in the grammar pool must use the
  -     * symbols from the specified symbol table.
  -     * 
  -     * @param symbolTable The symbol table.
  -     * @param grammarPool The grammar pool.
  +     * Initialize the parser with all the components specified via the
  +     * properties plus any missing ones. This method MUST be called before
  +     * parsing. It is not called from the constructor though, so that the
  +     * application can pass in any components it wants by presetting the
  +     * relevant property.
        */
  -    public DOMParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  -        super(symbolTable);
  +    public void initialize() {
  +        super.initialize();
   
           // set default features
           final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
  @@ -162,32 +150,49 @@
           fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
           final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
           fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
  -
  -        // create and register components
  -        final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  -        fProperties.put(SYMBOL_TABLE, fSymbolTable);
   
  -        fGrammarPool = grammarPool;
  +        // create and register missing components
           final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  -        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +        fGrammarPool = (GrammarPool) fProperties.get(GRAMMAR_POOL);
  +        if (fGrammarPool == null) {
  +            fGrammarPool = new GrammarPool();
  +            fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +        }
   
  -        fScanner = createDocumentScanner();
           final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  -        fProperties.put(DOCUMENT_SCANNER, fScanner);
  +        fScanner = (XMLDocumentScanner) fProperties.get(DOCUMENT_SCANNER);
  +        if (fScanner == null) {
  +            fScanner = createDocumentScanner();
  +            fProperties.put(DOCUMENT_SCANNER, fScanner);
  +        }
  +        fComponents.add(fScanner);
   
  -        fDTDScanner = createDTDScanner();
           final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  -        fProperties.put(DTD_SCANNER, fDTDScanner);
  +        fDTDScanner = (XMLDTDScanner) fProperties.get(DTD_SCANNER);
  +        if (fDTDScanner == null) {
  +            fDTDScanner = createDTDScanner();
  +            fProperties.put(DTD_SCANNER, fDTDScanner);
  +        }
  +        fComponents.add(fDTDScanner);
   
  -        fValidator = createValidator();
           final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
  -        fProperties.put(VALIDATOR, fValidator);
  +        fValidator = (XMLValidator) fProperties.get(VALIDATOR);
  +        if (fValidator == null) {
  +            fValidator = createValidator();
  +            fProperties.put(VALIDATOR, fValidator);
  +        }
  +        fComponents.add(fValidator);
           
  -        fDatatypeValidatorFactory = createDatatypeValidatorFactory();
           final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  -        fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
  +        fDatatypeValidatorFactory = (DatatypeValidatorFactory)
  +            fProperties.get(DATATYPE_VALIDATOR_FACTORY);
  +        if (fDatatypeValidatorFactory == null) {
  +            fDatatypeValidatorFactory = createDatatypeValidatorFactory();
  +            fProperties.put(DATATYPE_VALIDATOR_FACTORY,
  +                            fDatatypeValidatorFactory);
  +        }
   
  -    } // <init>(SymbolTable,GrammarPool)
  +    } // initialize()
   
       //
       // XMLParser methods
  @@ -199,8 +204,6 @@
        * @throws SAXException Thrown if an error occurs during initialization.
        */
       protected void reset() throws SAXException {
  -        super.reset();
  -
   
           // setup document pipeline
           fScanner.setDocumentHandler(fValidator);
  @@ -211,14 +214,11 @@
           fValidator.setDTDHandler(this);
   
           // setup dtd content model pipeline
  -        /***/
           fDTDScanner.setDTDContentModelHandler(fValidator);
           fValidator.setDTDContentModelHandler(this);
   
  -        // reset every component
  -        fScanner.reset(this);
  -        fDTDScanner.reset(this);
  -        fValidator.reset(this);
  +        // the following will reset every component
  +        super.reset();
   
       } // reset()
   
  @@ -227,82 +227,6 @@
       //
   
       /**
  -     * Set the state of a feature.
  -     * <p>
  -     * The feature name is any fully-qualified URI.  It is
  -     * possible for an XMLReader to recognize a feature name but
  -     * to be unable to set its value; this is especially true
  -     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
  -     * which has no way of affecting whether the underlying parser is
  -     * validating, for example.
  -     * <p>
  -     * Some feature values may be immutable or mutable only 
  -     * in specific contexts, such as before, during, or after 
  -     * a parse.
  -     *
  -     * @param name The feature name, which is a fully-qualified URI.
  -     * @param state The requested state of the feature (true or false).
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException When the
  -     *            XMLReader does not recognize the feature name.
  -     * @exception org.xml.sax.SAXNotSupportedException When the
  -     *            XMLReader recognizes the feature name but 
  -     *            cannot set the requested value.
  -     *
  -     * @see #getFeature
  -     */
  -    public void setFeature(String featureId, boolean state)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        super.setFeature(featureId, state);
  -
  -        // forward to every component
  -        fScanner.setFeature(featureId, state);
  -        fDTDScanner.setFeature(featureId, state);
  -        fValidator.setFeature(featureId, state);
  -
  -    } // setFeature(String,boolean)
  -
  -    /**
  -     * Set the value of a property.
  -     * <p>
  -     * The property name is any fully-qualified URI.  It is
  -     * possible for an XMLReader to recognize a property name but
  -     * to be unable to set its value; this is especially true
  -     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
  -     * Parser}.
  -     * <p>
  -     * Some property values may be immutable or mutable only 
  -     * in specific contexts, such as before, during, or after 
  -     * a parse.
  -     * <p>
  -     * This method is also the standard mechanism for setting
  -     * extended handlers.
  -     *
  -     * @param name The property name, which is a fully-qualified URI.
  -     * @param state The requested value for the property.
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException When the
  -     *            XMLReader does not recognize the property name.
  -     * @exception org.xml.sax.SAXNotSupportedException When the
  -     *            XMLReader recognizes the property name but 
  -     *            cannot set the requested value.
  -     *
  -     * @see #getProperty
  -     */
  -    public void setProperty(String propertyId, Object value)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        super.setProperty(propertyId, value);
  -
  -        // forward to every component
  -        fScanner.setProperty(propertyId, value);
  -        fDTDScanner.setProperty(propertyId, value);
  -        fValidator.setProperty(propertyId, value);
  -
  -    } // setProperty(String,Object)
  -
  -    /**
        * Parses the specified input source.
        *
        * @param source The input source.
  @@ -316,6 +240,9 @@
           if (fParseInProgress) {
               // REVISIT - need to add new error message
               throw new SAXException("FWK005 parse may not be called while parsing.");
  +        }
  +        else if (fNeedInitialize) {
  +            initialize();
           }
   
           try {
  
  
  
  1.12.2.19 +47 -120   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.12.2.18
  retrieving revision 1.12.2.19
  diff -u -r1.12.2.18 -r1.12.2.19
  --- SAXParser.java	2001/02/13 19:04:58	1.12.2.18
  +++ SAXParser.java	2001/02/13 22:51:26	1.12.2.19
  @@ -85,7 +85,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: SAXParser.java,v 1.12.2.18 2001/02/13 19:04:58 lehors Exp $ */
  + * @version $Id: SAXParser.java,v 1.12.2.19 2001/02/13 22:51:26 lehors Exp $ */
   public class SAXParser
       extends AbstractSAXParser {
   
  @@ -126,32 +126,20 @@
       //
   
       /**
  -     * Constructs a document parser using the default symbol table
  -     * and grammar pool.
  +     * Constructs a SAX parser.
        */
       public SAXParser() {
  -        this(new SymbolTable(), new GrammarPool());
  -    } // <init>()
  +    } // <init>
   
  -    /** 
  -     * Constructs a document parser using the specified symbol table
  -     * and a default grammar pool.
  -     */
  -    public SAXParser(SymbolTable symbolTable) {
  -        this(symbolTable, new GrammarPool());
  -    } // <init>(SymbolTable)
  -
       /**
  -     * Constructor allowing to specify the symbol table and grammar pool 
  -     * to use. The symbol table and grammar pool are specified together
  -     * because the grammars contained in the grammar pool must use the
  -     * symbols from the specified symbol table.
  -     * 
  -     * @param symbolTable The symbol table.
  -     * @param grammarPool The grammar pool.
  +     * Initialize the parser with all the components specified via the
  +     * properties plus any missing ones. This method MUST be called before
  +     * parsing. It is not called from the constructor though, so that the
  +     * application can pass in any components it wants by presetting the
  +     * relevant property.
        */
  -    public SAXParser(SymbolTable symbolTable, GrammarPool grammarPool) {
  -        super(symbolTable);
  +    public void initialize() {
  +        super.initialize();
   
           // set default features
           final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
  @@ -162,32 +150,49 @@
           fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
           final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
           fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
  -
  -        // create and register components
  -        final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  -        fProperties.put(SYMBOL_TABLE, fSymbolTable);
   
  -        fGrammarPool = grammarPool;
  +        // create and register missing components
           final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
  -        fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +        fGrammarPool = (GrammarPool) fProperties.get(GRAMMAR_POOL);
  +        if (fGrammarPool == null) {
  +            fGrammarPool = new GrammarPool();
  +            fProperties.put(GRAMMAR_POOL, fGrammarPool);
  +        }
   
  -        fScanner = createDocumentScanner();
           final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  -        fProperties.put(DOCUMENT_SCANNER, fScanner);
  +        fScanner = (XMLDocumentScanner) fProperties.get(DOCUMENT_SCANNER);
  +        if (fScanner == null) {
  +            fScanner = createDocumentScanner();
  +            fProperties.put(DOCUMENT_SCANNER, fScanner);
  +        }
  +        fComponents.add(fScanner);
   
  -        fDTDScanner = createDTDScanner();
           final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  -        fProperties.put(DTD_SCANNER, fDTDScanner);
  +        fDTDScanner = (XMLDTDScanner) fProperties.get(DTD_SCANNER);
  +        if (fDTDScanner == null) {
  +            fDTDScanner = createDTDScanner();
  +            fProperties.put(DTD_SCANNER, fDTDScanner);
  +        }
  +        fComponents.add(fDTDScanner);
   
  -        fValidator = createValidator();
           final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
  -        fProperties.put(VALIDATOR, fValidator);
  +        fValidator = (XMLValidator) fProperties.get(VALIDATOR);
  +        if (fValidator == null) {
  +            fValidator = createValidator();
  +            fProperties.put(VALIDATOR, fValidator);
  +        }
  +        fComponents.add(fValidator);
           
  -        fDatatypeValidatorFactory = createDatatypeValidatorFactory();
           final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  -        fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
  +        fDatatypeValidatorFactory = (DatatypeValidatorFactory)
  +            fProperties.get(DATATYPE_VALIDATOR_FACTORY);
  +        if (fDatatypeValidatorFactory == null) {
  +            fDatatypeValidatorFactory = createDatatypeValidatorFactory();
  +            fProperties.put(DATATYPE_VALIDATOR_FACTORY,
  +                            fDatatypeValidatorFactory);
  +        }
   
  -    } // <init>(SymbolTable,GrammarPool)
  +    } // initialize()
   
       //
       // XMLParser methods
  @@ -199,8 +204,6 @@
        * @throws SAXException Thrown if an error occurs during initialization.
        */
       protected void reset() throws SAXException {
  -        super.reset();
  -
   
           // setup document pipeline
           fScanner.setDocumentHandler(fValidator);
  @@ -211,14 +214,11 @@
           fValidator.setDTDHandler(this);
   
           // setup dtd content model pipeline
  -        /***/
           fDTDScanner.setDTDContentModelHandler(fValidator);
           fValidator.setDTDContentModelHandler(this);
   
  -        // reset every component
  -        fScanner.reset(this);
  -        fDTDScanner.reset(this);
  -        fValidator.reset(this);
  +        // the following will reset every component
  +        super.reset();
   
       } // reset()
   
  @@ -227,82 +227,6 @@
       //
   
       /**
  -     * Set the state of a feature.
  -     * <p>
  -     * The feature name is any fully-qualified URI.  It is
  -     * possible for an XMLReader to recognize a feature name but
  -     * to be unable to set its value; this is especially true
  -     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
  -     * which has no way of affecting whether the underlying parser is
  -     * validating, for example.
  -     * <p>
  -     * Some feature values may be immutable or mutable only 
  -     * in specific contexts, such as before, during, or after 
  -     * a parse.
  -     *
  -     * @param name The feature name, which is a fully-qualified URI.
  -     * @param state The requested state of the feature (true or false).
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException When the
  -     *            XMLReader does not recognize the feature name.
  -     * @exception org.xml.sax.SAXNotSupportedException When the
  -     *            XMLReader recognizes the feature name but 
  -     *            cannot set the requested value.
  -     *
  -     * @see #getFeature
  -     */
  -    public void setFeature(String featureId, boolean state)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        super.setFeature(featureId, state);
  -
  -        // forward to every component
  -        fScanner.setFeature(featureId, state);
  -        fDTDScanner.setFeature(featureId, state);
  -        fValidator.setFeature(featureId, state);
  -
  -    } // setFeature(String,boolean)
  -
  -    /**
  -     * Set the value of a property.
  -     * <p>
  -     * The property name is any fully-qualified URI.  It is
  -     * possible for an XMLReader to recognize a property name but
  -     * to be unable to set its value; this is especially true
  -     * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
  -     * Parser}.
  -     * <p>
  -     * Some property values may be immutable or mutable only 
  -     * in specific contexts, such as before, during, or after 
  -     * a parse.
  -     * <p>
  -     * This method is also the standard mechanism for setting
  -     * extended handlers.
  -     *
  -     * @param name The property name, which is a fully-qualified URI.
  -     * @param state The requested value for the property.
  -     *
  -     * @exception org.xml.sax.SAXNotRecognizedException When the
  -     *            XMLReader does not recognize the property name.
  -     * @exception org.xml.sax.SAXNotSupportedException When the
  -     *            XMLReader recognizes the property name but 
  -     *            cannot set the requested value.
  -     *
  -     * @see #getProperty
  -     */
  -    public void setProperty(String propertyId, Object value)
  -        throws SAXNotRecognizedException, SAXNotSupportedException {
  -
  -        super.setProperty(propertyId, value);
  -
  -        // forward to every component
  -        fScanner.setProperty(propertyId, value);
  -        fDTDScanner.setProperty(propertyId, value);
  -        fValidator.setProperty(propertyId, value);
  -
  -    } // setProperty(String,Object)
  -
  -    /**
        * Parses the specified input source.
        *
        * @param source The input source.
  @@ -316,6 +240,9 @@
           if (fParseInProgress) {
               // REVISIT - need to add new error message
               throw new SAXException("FWK005 parse may not be called while parsing.");
  +        }
  +        else if (fNeedInitialize) {
  +            initialize();
           }
   
           try {
  
  
  
  1.1.2.32  +2 -10     xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java
  
  Index: XMLDocumentParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java,v
  retrieving revision 1.1.2.31
  retrieving revision 1.1.2.32
  diff -u -r1.1.2.31 -r1.1.2.32
  --- XMLDocumentParser.java	2001/02/13 19:04:58	1.1.2.31
  +++ XMLDocumentParser.java	2001/02/13 22:51:26	1.1.2.32
  @@ -1,3 +1,4 @@
  +
   /*
    * The Apache Software License, Version 1.1
    *
  @@ -90,7 +91,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLDocumentParser.java,v 1.1.2.31 2001/02/13 19:04:58 lehors Exp $
  + * @version $Id: XMLDocumentParser.java,v 1.1.2.32 2001/02/13 22:51:26 lehors Exp $
    */
   public abstract class XMLDocumentParser
       extends XMLParser
  @@ -118,16 +119,7 @@
        * and grammar pool.
        */
       protected XMLDocumentParser() {
  -        this(new SymbolTable());
       } // <init>()
  -
  -    /** 
  -     * Constructs a document parser using the specified symbol table
  -     * and a default grammar pool.
  -     */
  -    protected XMLDocumentParser(SymbolTable symbolTable) {
  -        super(symbolTable);
  -    } // <init>(SymbolTable)
   
       //
       // XMLDocumentHandler methods
  
  
  
  1.1.2.19  +61 -26    xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java,v
  retrieving revision 1.1.2.18
  retrieving revision 1.1.2.19
  diff -u -r1.1.2.18 -r1.1.2.19
  --- XMLParser.java	2001/01/05 09:33:27	1.1.2.18
  +++ XMLParser.java	2001/02/13 22:51:26	1.1.2.19
  @@ -60,13 +60,16 @@
   import java.io.InputStream;
   import java.io.IOException;
   import java.io.Reader;
  +import java.util.Hashtable;
   import java.util.Locale;
  +import java.util.Vector;
   
   import org.apache.xerces.impl.Constants;
   import org.apache.xerces.impl.XMLEntityManager;
   import org.apache.xerces.impl.XMLErrorReporter;
   import org.apache.xerces.impl.msg.XMLMessageFormatter;
   import org.apache.xerces.util.SymbolTable;
  +import org.apache.xerces.xni.XMLComponent;
   import org.apache.xerces.xni.XMLComponentManager;
   
   import org.xml.sax.EntityResolver;
  @@ -77,8 +80,6 @@
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
   
  -import java.util.Hashtable;
  -
   /**
    * Base class of all XML-related parsers.
    * <p>
  @@ -106,7 +107,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLParser.java,v 1.1.2.18 2001/01/05 09:33:27 andyc Exp $
  + * @version $Id: XMLParser.java,v 1.1.2.19 2001/02/13 22:51:26 lehors Exp $
    */
   public abstract class XMLParser
       implements XMLComponentManager {
  @@ -139,23 +140,22 @@
       /** Features. */
       protected Hashtable fFeatures;
   
  +    /** Components. */
  +    protected Vector fComponents;
  +
  +    protected boolean fNeedInitialize;
  +
       //
       // Constructors
       //
   
       /**
  -     * Default Constructor. Creates a parser with its own SymbolTable.
  +     * Default Constructor.
        */
       protected XMLParser() {
  -        this(new SymbolTable());
  -    } // <init>()
   
  -    /**
  -     * Constructor allowing the SymbolTable to be specified.
  -     * 
  -     * @param symbolTable 
  -     */
  -    protected XMLParser(SymbolTable symbolTable) {
  +        // create a vector to hold all the components in use
  +        fComponents = new Vector();
   
           // create table for features and properties
           fFeatures = new Hashtable();
  @@ -180,19 +180,44 @@
           fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
           final String LOAD_EXTERNAL_DTD = Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
           fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
  +
  +        fNeedInitialize = true;
  +
  +    } // <init>
   
  -        // create and register components
  -        fSymbolTable = symbolTable;
  +    /**
  +     * Initialize the parser with all the components specified via the
  +     * properties plus any missing ones. This method MUST be called before
  +     * parsing. It is not called from the constructor though, so that the
  +     * application can pass in any components it wants by presetting the
  +     * relevant property.
  +     */
  +    protected void initialize() {
  +
  +        // create and register missing components
           final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  -        fProperties.put(SYMBOL_TABLE, fSymbolTable);
  +        fSymbolTable = (SymbolTable) fProperties.get(SYMBOL_TABLE);
  +        if (fSymbolTable == null) {
  +            fSymbolTable = new SymbolTable();
  +            fProperties.put(SYMBOL_TABLE, fSymbolTable);
  +        }
   
  -        fEntityManager = createEntityManager();
           final String ENTITY_MANAGER = Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
  -        fProperties.put(ENTITY_MANAGER, fEntityManager);
  +        fEntityManager = (XMLEntityManager) fProperties.get(ENTITY_MANAGER);
  +        if (fEntityManager == null) {
  +            fEntityManager = createEntityManager();
  +            fProperties.put(ENTITY_MANAGER, fEntityManager);
  +        }
  +        fComponents.add(fEntityManager);
   
  -        fErrorReporter = createErrorReporter( fEntityManager.getEntityScanner() );
           final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
  -        fProperties.put(ERROR_REPORTER, fErrorReporter);
  +        fErrorReporter = (XMLErrorReporter) fProperties.get(ERROR_REPORTER);
  +        if (fErrorReporter == null) {
  +            fErrorReporter =
  +                createErrorReporter(fEntityManager.getEntityScanner());
  +            fProperties.put(ERROR_REPORTER, fErrorReporter);
  +        }
  +        fComponents.add(fErrorReporter);
   
           fLocator = (Locator) fEntityManager.getEntityScanner();
   
  @@ -207,8 +232,9 @@
           catch (SAXException e) {
               // ignore
           }
  +        fNeedInitialize = false;
   
  -    } // <init>(SymbolTable)
  +    } // initialize()
   
       //
       // Public methods
  @@ -344,8 +370,11 @@
           checkFeature(featureId);
   
           // forward to every component
  -        fEntityManager.setFeature(featureId, state);
  -        fErrorReporter.setFeature(featureId, state);
  +        int count = fComponents.size();
  +        for (int i = 0; i < count; i++) {
  +            XMLComponent c = (XMLComponent) fComponents.elementAt(i);
  +            c.setFeature(featureId, state);
  +        }
           // then store the information
           fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
   
  @@ -363,8 +392,11 @@
           checkProperty(propertyId);
   
           // forward to every component
  -        fEntityManager.setProperty(propertyId, value);
  -        fErrorReporter.setProperty(propertyId, value);
  +        int count = fComponents.size();
  +        for (int i = 0; i < count; i++) {
  +            XMLComponent c = (XMLComponent) fComponents.elementAt(i);
  +            c.setProperty(propertyId, value);
  +        }
           // then store the information
           fProperties.put(propertyId, value);
   
  @@ -439,8 +471,11 @@
       protected void reset() throws SAXException {
   
           // reset every component
  -        fEntityManager.reset(this);
  -        fErrorReporter.reset(this);
  +        int count = fComponents.size();
  +        for (int i = 0; i < count; i++) {
  +            XMLComponent c = (XMLComponent) fComponents.elementAt(i);
  +            c.reset(this);
  +        }
   
       } // reset()