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 2003/11/07 01:26:18 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers XML11Configuration.java

elena       2003/11/06 16:26:18

  Modified:    java/src/org/apache/xerces/impl Constants.java
                        XMLDocumentFragmentScannerImpl.java
                        XMLDocumentScannerImpl.java XMLEntityManager.java
                        XMLScanner.java
               java/src/org/apache/xerces/impl/dtd XMLDTDProcessor.java
                        XMLDTDValidator.java
               java/src/org/apache/xerces/impl/xs XMLSchemaLoader.java
                        XMLSchemaValidator.java
               java/src/org/apache/xerces/parsers XML11Configuration.java
  Log:
  Re-implement XML11Configuration:
  
  1. Remove dependency on the configurations that were designed to handle only XML 1.0 documents.
  Relying on those configurations might have caused several bugs in reset, configurePipeline.
  2. Instead of having one vector of components, user 3 vectors: one for XML 1.0 components, one for
  XML 1.1. components, and one vector for the components that do not depend on XML version, such as XMLEntityManager
  3. Add a new internal feature "internal/parser-settings" that is set by the configuration to notify the components if anything in the configuration settings have been changed.
  
  Make sure that components in the pipeline query "internal/parser-settings" feature to find out if they need to reset features and properties.
  This change improves the performance for non-validating SAX parser by ~14%. It improves schema validation with grammar cashing by ~9%.
  
  Revision  Changes    Path
  1.33      +9 -1      xml-xerces/java/src/org/apache/xerces/impl/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Constants.java	6 Aug 2003 13:52:34 -0000	1.32
  +++ Constants.java	7 Nov 2003 00:26:17 -0000	1.33
  @@ -271,6 +271,13 @@
   
       /** Standard URI conformant feature ("standard-uri-conformant"). */
       public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant";
  +    
  +	/** Internal performance related feature: 
  +	 * false - the parser settings (features/properties) have not changed between 2 parses
  +	 * true - the parser settings have changed between 2 parses  
  +	 * NOTE: this feature should only be set by the parser configuration.
  +	 */
  +	public static final String PARSER_SETTINGS = "internal/parser-settings";
   
       // xerces properties
   
  @@ -297,6 +304,7 @@
   
       /** Entity manager property ("internal/entity-manager"). */
       public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
  +    
   
       /** Input buffer size property ("input-buffer-size"). */
       public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
  
  
  
  1.40      +20 -18    xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java
  
  Index: XMLDocumentFragmentScannerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- XMLDocumentFragmentScannerImpl.java	2 Nov 2003 05:56:06 -0000	1.39
  +++ XMLDocumentFragmentScannerImpl.java	7 Nov 2003 00:26:17 -0000	1.40
  @@ -374,25 +374,27 @@
           // sax features
           fAttributes.setNamespaces(fNamespaces);
   
  -        // xerces features
  -        try {
  -            fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS);
  -        }
  -        catch (XMLConfigurationException e) {
  -            fNotifyBuiltInRefs = false;
  -        }
  -
  -        // initialize vars
  -        fMarkupDepth = 0;
  -        fCurrentElement = null;
  -        fElementStack.clear();
  -        fHasExternalDTD = false;
  -        fStandalone = false;
  +		// initialize vars
  +		fMarkupDepth = 0;
  +		fCurrentElement = null;
  +		fElementStack.clear();
  +		fHasExternalDTD = false;
  +		fStandalone = false;
   
  -        // setup dispatcher
  -        setScannerState(SCANNER_STATE_CONTENT);
  -        setDispatcher(fContentDispatcher);
  +		// setup dispatcher
  +		setScannerState(SCANNER_STATE_CONTENT);
  +		setDispatcher(fContentDispatcher);
           
  +
  +        if (!fParserSettings) {
  +            // xerces features
  +            try {
  +                fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS);
  +            } catch (XMLConfigurationException e) {
  +                fNotifyBuiltInRefs = false;
  +            }
  +        }
  +
       } // reset(XMLComponentManager)
   
       /**
  
  
  
  1.34      +14 -4     xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java
  
  Index: XMLDocumentScannerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- XMLDocumentScannerImpl.java	24 Jun 2003 21:56:58 -0000	1.33
  +++ XMLDocumentScannerImpl.java	7 Nov 2003 00:26:17 -0000	1.34
  @@ -150,6 +150,8 @@
       /** property identifier:  NamespaceContext */
       protected static final String NAMESPACE_CONTEXT =
           Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
  +        
  +
   
       // recognized features and properties
   
  @@ -299,6 +301,17 @@
           fDoctypePublicId = null;
           fDoctypeSystemId = null;
           fSeenDoctypeDecl = false;
  +		fScanningDTD = false;
  +       
  +
  +		if (!fParserSettings) {
  +			// parser settings have not been changed
  +			fNamespaceContext.reset();
  +			// setup dispatcher
  +			setScannerState(SCANNER_STATE_XML_DECL);
  +			setDispatcher(fXMLDeclDispatcher);
  +			return;
  +		}
   
           // xerces features
           try {
  @@ -331,9 +344,6 @@
               fNamespaceContext = new NamespaceSupport();
           }
           fNamespaceContext.reset();
  -
  -        // initialize vars
  -        fScanningDTD = false;
           
           // setup dispatcher
           setScannerState(SCANNER_STATE_XML_DECL);
  
  
  
  1.68      +19 -3     xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java
  
  Index: XMLEntityManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- XMLEntityManager.java	2 Nov 2003 05:56:06 -0000	1.67
  +++ XMLEntityManager.java	7 Nov 2003 00:26:17 -0000	1.68
  @@ -155,6 +155,9 @@
       /** Feature identifier: standard uri conformant */
       protected static final String STANDARD_URI_CONFORMANT =
       Constants.XERCES_FEATURE_PREFIX +Constants.STANDARD_URI_CONFORMANT_FEATURE;
  +    
  +	protected static final String PARSER_SETTINGS = 
  +		Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;	
   
       // property identifiers
   
  @@ -1099,15 +1102,15 @@
           if(version == Constants.XML_VERSION_1_0) {
               if(fXML10EntityScanner == null) {
                   fXML10EntityScanner = new XMLEntityScanner();
  -                fXML10EntityScanner.reset(fSymbolTable, this, fErrorReporter);
               }
  +			fXML10EntityScanner.reset(fSymbolTable, this, fErrorReporter);
               fEntityScanner = fXML10EntityScanner;
               fEntityScanner.setCurrentEntity(fCurrentEntity);
           } else {
               if(fXML11EntityScanner == null) {
                   fXML11EntityScanner = new XML11EntityScanner();
  -                fXML11EntityScanner.reset(fSymbolTable, this, fErrorReporter);
               }
  +			fXML11EntityScanner.reset(fSymbolTable, this, fErrorReporter);
               fEntityScanner = fXML11EntityScanner;
               fEntityScanner.setCurrentEntity(fCurrentEntity);
           }
  @@ -1165,6 +1168,19 @@
        */
       public void reset(XMLComponentManager componentManager)
           throws XMLConfigurationException {
  +        	
  +		boolean parser_settings;
  +		try {
  +				parser_settings = componentManager.getFeature(PARSER_SETTINGS);
  +		} catch (XMLConfigurationException e) {
  +				parser_settings = true;
  +		}
  +
  +		if (!parser_settings) {
  +			// parser settings have not been changed
  +			reset();
  +			return;
  +		}
   
           // sax features
           try {
  
  
  
  1.37      +22 -2     xml-xerces/java/src/org/apache/xerces/impl/XMLScanner.java
  
  Index: XMLScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLScanner.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- XMLScanner.java	25 Jul 2003 19:50:02 -0000	1.36
  +++ XMLScanner.java	7 Nov 2003 00:26:17 -0000	1.37
  @@ -116,6 +116,9 @@
       /** Feature identifier: notify character references. */
       protected static final String NOTIFY_CHAR_REFS =
           Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_CHAR_REFS_FEATURE;
  +	
  +	protected static final String PARSER_SETTINGS = 
  +				Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
   
       // property identifiers
   
  @@ -139,6 +142,7 @@
       //
       // Data
       //
  +    
   
       // features
   
  @@ -153,7 +157,10 @@
   
       /** Character references notification. */
       protected boolean fNotifyCharRefs = false;
  -
  +    
  +    /** Internal parser-settings feature */
  +	protected boolean fParserSettings = true;
  +	
       // properties
   
       /** Symbol table. */
  @@ -246,6 +253,18 @@
       public void reset(XMLComponentManager componentManager)
           throws XMLConfigurationException {
   
  +		try {
  +			fParserSettings = componentManager.getFeature(PARSER_SETTINGS);
  +		} catch (XMLConfigurationException e) {
  +			fParserSettings = true;
  +		}
  +
  +		if (!fParserSettings) {
  +			// parser settings have not been changed
  +			init();
  +			return;
  +		}
  +
           // Xerces properties
           fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
           fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
  @@ -271,6 +290,7 @@
           catch (XMLConfigurationException e) {
               fNotifyCharRefs = false;
           }
  +        init();
   
       } // reset(XMLComponentManager)
   
  
  
  
  1.10      +46 -34    xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java
  
  Index: XMLDTDProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDProcessor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XMLDTDProcessor.java	22 Aug 2003 16:27:26 -0000	1.9
  +++ XMLDTDProcessor.java	7 Nov 2003 00:26:18 -0000	1.10
  @@ -131,6 +131,9 @@
       /** Feature identifier: warn on duplicate attdef */
       protected static final String WARN_ON_DUPLICATE_ATTDEF = 
           Constants.XERCES_FEATURE_PREFIX +Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE; 
  +        
  +	protected static final String PARSER_SETTINGS = 
  +			Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
   
       // property identifiers
   
  @@ -313,51 +316,66 @@
        *                      SAXNotRecognizedException or a
        *                      SAXNotSupportedException.
        */
  -    public void reset(XMLComponentManager componentManager)
  -            throws XMLConfigurationException {
  +    public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
  +       
  +        boolean parser_settings;
  +        try {
  +            parser_settings = componentManager.getFeature(PARSER_SETTINGS);
  +        } catch (XMLConfigurationException e) {
  +            parser_settings = true;
  +        }
  +
  +        if (!parser_settings) {
  +            // parser settings have not been changed
  +			reset();
  +            return;
  +        }
   
           // sax features
           try {
               fValidation = componentManager.getFeature(VALIDATION);
  -        }
  -        catch (XMLConfigurationException e) {
  +        } catch (XMLConfigurationException e) {
               fValidation = false;
           }
           try {
  -            fDTDValidation = !(componentManager.getFeature(Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE));
  -        }
  -        catch (XMLConfigurationException e) {
  +            fDTDValidation =
  +                !(componentManager
  +                    .getFeature(
  +                        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE));
  +        } catch (XMLConfigurationException e) {
               // must be in a schema-less configuration!
               fDTDValidation = true;
           }
   
           // Xerces features
  -        
  +
           try {
               fWarnDuplicateAttdef = componentManager.getFeature(WARN_ON_DUPLICATE_ATTDEF);
  -        }
  -        catch (XMLConfigurationException e) {
  +        } catch (XMLConfigurationException e) {
               fWarnDuplicateAttdef = false;
           }
   
  -
           // get needed components
  -        fErrorReporter = (XMLErrorReporter)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.ERROR_REPORTER_PROPERTY);
  -        fSymbolTable = (SymbolTable)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.SYMBOL_TABLE_PROPERTY);
  +        fErrorReporter =
  +            (XMLErrorReporter) componentManager.getProperty(
  +                Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
  +        fSymbolTable =
  +            (SymbolTable) componentManager.getProperty(
  +                Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
           try {
  -            fGrammarPool= (XMLGrammarPool)componentManager.getProperty(GRAMMAR_POOL);
  +            fGrammarPool = (XMLGrammarPool) componentManager.getProperty(GRAMMAR_POOL);
           } catch (XMLConfigurationException e) {
               fGrammarPool = null;
           }
           try {
  -            fValidator = (XMLDTDValidator)componentManager.getProperty(DTD_VALIDATOR);
  +            fValidator = (XMLDTDValidator) componentManager.getProperty(DTD_VALIDATOR);
           } catch (XMLConfigurationException e) {
               fValidator = null;
           } catch (ClassCastException e) {
               fValidator = null;
           }
           // we get our grammarBucket from the validator...
  -        if(fValidator != null) {
  +        if (fValidator != null) {
               fGrammarBucket = fValidator.getGrammarBucket();
           } else {
               fGrammarBucket = null;
  @@ -374,7 +392,17 @@
   
           fNDataDeclNotations.clear();
   
  -        init();
  +        // datatype validators
  +        if (fValidation) {
  +
  +            if (fNotationEnumVals == null) {
  +                fNotationEnumVals = new Hashtable();
  +            }
  +            fNotationEnumVals.clear();
  +
  +            fTableOfIDAttributeNames = new Hashtable();
  +            fTableOfNOTATIONAttributeNames = new Hashtable();
  +        }
   
       }
       /**
  @@ -1630,22 +1658,6 @@
           return false;
       }
   
  -    /** initialization */
  -    private void init() {
  -
  -        // datatype validators
  -        if (fValidation) {
  -
  -            if (fNotationEnumVals == null) {
  -                fNotationEnumVals = new Hashtable(); 
  -            }
  -            fNotationEnumVals.clear();
  -
  -            fTableOfIDAttributeNames = new Hashtable();
  -            fTableOfNOTATIONAttributeNames = new Hashtable();
  -        }
  -
  -    } // init()
       
       protected boolean isValidNmtoken(String nmtoken) {
           return XMLChar.isValidNmtoken(nmtoken);
  
  
  
  1.54      +27 -8     xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java
  
  Index: XMLDTDValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- XMLDTDValidator.java	4 Nov 2003 05:15:16 -0000	1.53
  +++ XMLDTDValidator.java	7 Nov 2003 00:26:18 -0000	1.54
  @@ -149,6 +149,9 @@
       /** Feature identifier: warn on duplicate attdef */
       protected static final String WARN_ON_DUPLICATE_ATTDEF = 
       Constants.XERCES_FEATURE_PREFIX +Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE; 
  +    
  +	protected static final String PARSER_SETTINGS = 
  +		Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;	
   
   
   
  @@ -455,6 +458,26 @@
   
           fRootElement.clear();
   
  +		fValidationState.resetIDTables();
  +		
  +		fGrammarBucket.clear();
  +		fElementDepth = -1;                      
  +		fElementChildrenLength = 0;
  +        
  +        boolean parser_settings;
  +        try {
  +        	parser_settings = componentManager.getFeature(PARSER_SETTINGS);  	
  +        }
  +        catch (XMLConfigurationException e){
  +        	parser_settings = true;
  +        }
  +        
  +        if (!parser_settings){
  +        	// parser settings have not been changed
  +			fValidationManager.addValidationState(fValidationState);
  +        	return;
  +        }
  +
           // sax features
           try {
               fNamespaces = componentManager.getFeature(NAMESPACES);
  @@ -500,8 +523,7 @@
           }
   
           fValidationManager= (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
  -        fValidationManager.addValidationState(fValidationState);
  -        fValidationState.resetIDTables();
  +        fValidationManager.addValidationState(fValidationState);      
           fValidationState.setUsingNamespaces(fNamespaces);
           
           // get needed components
  @@ -512,12 +534,9 @@
           } catch (XMLConfigurationException e) {
               fGrammarPool = null;
           }
  -        fGrammarBucket.clear();
  -        fDatatypeValidatorFactory = (DTDDVFactory)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY);
   
  -        fElementDepth = -1;                      
  -        fElementChildrenLength = 0;
  -        init();
  +        fDatatypeValidatorFactory = (DTDDVFactory)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY);
  +		init();
   
       } // reset(XMLComponentManager)
   
  
  
  
  1.19      +127 -8    xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
  
  Index: XMLSchemaLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XMLSchemaLoader.java	28 May 2003 15:01:15 -0000	1.18
  +++ XMLSchemaLoader.java	7 Nov 2003 00:26:18 -0000	1.19
  @@ -57,6 +57,8 @@
   
   package org.apache.xerces.impl.xs;
   
  +import org.apache.xerces.xni.parser.XMLComponent;
  +import org.apache.xerces.xni.parser.XMLComponentManager;
   import org.apache.xerces.xni.parser.XMLConfigurationException;
   import org.apache.xerces.xni.parser.XMLErrorHandler;
   import org.apache.xerces.xni.parser.XMLEntityResolver;
  @@ -105,7 +107,7 @@
    * @version $Id$
    */
   
  -public class XMLSchemaLoader implements XMLGrammarLoader {
  +public class XMLSchemaLoader implements XMLGrammarLoader, XMLComponent {
   
       // Feature identifiers:
   
  @@ -359,7 +361,7 @@
        *                  recognized or cannot be set.
        */
       public void setProperty(String propertyId,
  -                Object state) throws XMLConfigurationException, ClassCastException {
  +                Object state) throws XMLConfigurationException {
           if(propertyId.equals( SYMBOL_TABLE)) {
               fSymbolTable = (SymbolTable)state;
           } else if(propertyId.equals( ERROR_REPORTER)) {
  @@ -453,7 +455,7 @@
               }
           }
           
  -        if (useDeclPool) {
  +        if (fUseDeclPool) {
               fDeclPool.reset();
               fCMBuilder.setDeclPool(fDeclPool);
               fSchemaHandler.setDeclPool(fDeclPool);
  @@ -471,10 +473,8 @@
       // useDeclPool is only set to true when the validator invokes the loader,
       // and there is no grammar pool. that is, the grammar will never be
       // exposed to the application.
  -    private boolean useDeclPool = false;
  -    public void setUseDeclPool(boolean use) {
  -        useDeclPool = use;
  -    }
  +    private boolean fUseDeclPool = false;
  +    
       
       /**
        * Returns a Grammar object by parsing the contents of the
  @@ -861,6 +861,125 @@
           }
   
       } //locationArray
  +
  +	/* (non-Javadoc)
  +	 * @see org.apache.xerces.xni.parser.XMLComponent#getFeatureDefault(java.lang.String)
  +	 */
  +	public Boolean getFeatureDefault(String featureId) {
  +		// TODO Auto-generated method stub
  +		return null;
  +	}
  +
  +	/* (non-Javadoc)
  +	 * @see org.apache.xerces.xni.parser.XMLComponent#getPropertyDefault(java.lang.String)
  +	 */
  +	public Object getPropertyDefault(String propertyId) {
  +		// TODO Auto-generated method stub
  +		return null;
  +	}
  +
  +	/* (non-Javadoc)
  +	 * @see org.apache.xerces.xni.parser.XMLComponent#reset(org.apache.xerces.xni.parser.XMLComponentManager)
  +	 */
  +	public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
  +		
  +		fGrammarBucket.reset();
  +		
  +		// reinitialize grammar bucket
  +		initGrammarBucket();
  +        
  +		if (fUseDeclPool) {
  +			fDeclPool.reset();
  +			fCMBuilder.setDeclPool(fDeclPool);
  +			fSchemaHandler.setDeclPool(fDeclPool);
  +		} else {
  +			fCMBuilder.setDeclPool(null);
  +			fSchemaHandler.setDeclPool(null);
  +		}
  +
  +		fSubGroupHandler.reset();		
  +		
  +		if (componentManager == null)
  +			return;
  +		
  +		// set error reporter
  +		fErrorReporter = (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
  +		// set symbol table
  +		fSymbolTable = (SymbolTable) componentManager.getProperty(SYMBOL_TABLE);
  +		// set full validation to false
  +		fIsCheckedFully = false;
  +		
  +		fEntityResolver = (XMLEntityResolver) componentManager.getProperty(
  +			Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY);
  +			
  +		// get schema location properties
  +		try {
  +			fExternalSchemas = (String) componentManager.getProperty(SCHEMA_LOCATION);
  +			fExternalNoNSSchema =
  +				(String) componentManager.getProperty(SCHEMA_NONS_LOCATION);
  +		} catch (XMLConfigurationException e) {
  +			fExternalSchemas = null;
  +			fExternalNoNSSchema = null;
  +		}
  +		// get JAXP sources if available
  +		try {
  +			fJAXPSource = componentManager.getProperty(JAXP_SCHEMA_SOURCE);
  +			fJAXPProcessed = false;
  +
  +		} catch (XMLConfigurationException e) {
  +			fJAXPSource = null;
  +			fJAXPProcessed = false;
  +		}
  +		
  +		// clear grammars, and put the one for schema namespace there
  +		try {
  +			fGrammarPool = (XMLGrammarPool) componentManager.getProperty(XMLGRAMMAR_POOL);
  +		} catch (XMLConfigurationException e) {
  +			fGrammarPool = null;
  +		}
  +		
  +		 fUseDeclPool = (fGrammarPool == null);
  +		 
  +		try {
  +			fAllowJavaEncodings = componentManager.getFeature(ALLOW_JAVA_ENCODINGS);
  +		} catch (XMLConfigurationException e) {
  +		}
  +		try {
  +			fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT_FEATURE);
  +		} catch (XMLConfigurationException e) {
  +		}
  +		
  +		// get continue-after-fatal-error feature
  +		try {
  +			boolean fatalError = componentManager.getFeature(CONTINUE_AFTER_FATAL_ERROR);
  +			fErrorReporter.setFeature(CONTINUE_AFTER_FATAL_ERROR, fatalError);
  +		} catch (XMLConfigurationException e) {
  +		}
  +		initGrammarBucket();
  +		fSchemaHandler.reset(fErrorReporter, fEntityResolver,
  +				fSymbolTable, fGrammarPool, fAllowJavaEncodings, fStrictURI);
  +		 
  +		 
  +	}
  +	
  +	private void initGrammarBucket(){
  +		if(fGrammarPool != null) {
  +			Grammar [] initialGrammars = fGrammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
  +			for (int i = 0; i < initialGrammars.length; i++) {
  +				// put this grammar into the bucket, along with grammars
  +				// imported by it (directly or indirectly)
  +				if (!fGrammarBucket.putGrammar((SchemaGrammar)(initialGrammars[i]), true)) {
  +					// REVISIT: a conflict between new grammar(s) and grammars
  +					// in the bucket. What to do? A warning? An exception?
  +					fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
  +																 "GrammarConflict", null,
  +																 XMLErrorReporter.SEVERITY_WARNING);
  +				}
  +			}
  +		}
  +	}
  +	
  +	
   
   } // XMLGrammarLoader
   
  
  
  
  1.146     +57 -69    xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.145
  retrieving revision 1.146
  diff -u -r1.145 -r1.146
  --- XMLSchemaValidator.java	30 Sep 2003 21:35:32 -0000	1.145
  +++ XMLSchemaValidator.java	7 Nov 2003 00:26:18 -0000	1.146
  @@ -185,7 +185,10 @@
   	/** Feature identifier: whether to continue parsing a schema after a fatal error is encountered */
   	protected static final String CONTINUE_AFTER_FATAL_ERROR =
   		Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
  -
  +	
  +	protected static final String PARSER_SETTINGS = 
  +			Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
  +			
   	// property identifiers
   
   	/** Property identifier: symbol table. */
  @@ -295,6 +298,7 @@
   
   	// Validation features
   	protected boolean fDynamicValidation = false;
  +	protected boolean fSchemaDynamicValidation = false;
   	protected boolean fDoValidation = false;
   	protected boolean fFullChecking = false;
   	protected boolean fNormalizeData = true;
  @@ -1232,15 +1236,61 @@
   	 *                      SAXNotSupportedException.
   	 */
   	public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
  +        
  +        
  +		fIdConstraint = false;
  +		//reset XSDDescription
  +		fLocationPairs.clear();
  +
  +		// cleanup id table
  +		fValidationState.resetIDTables();
  +		
  +		//pass the component manager to the factory..
  +		nodeFactory.reset(componentManager);
  +
  +		// reset schema loader
  +		fSchemaLoader.reset(componentManager);
  +
  +		// initialize state
  +		fCurrentElemDecl = null;
  +		fCurrentCM = null;
  +		fCurrCMState = null;
  +		fSkipValidationDepth = -1;
  +		fNFullValidationDepth = -1;
  +		fNNoneValidationDepth = -1;
  +		fElementDepth = -1;
  +		fSubElement = false;
  +		fSchemaDynamicValidation = false;
   
  +		// datatype normalization
  +		fEntityRef = false;
  +		fInCDATA = false;
  +
  +		fMatcherStack.clear();
  +		fBaseURI = null;
  +		
   		// get error reporter
   		fXSIErrorReporter.reset((XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER));
  -		fSchemaLoader.setProperty(ERROR_REPORTER, fXSIErrorReporter.fErrorReporter);
  +        
  +		boolean parser_settings;
  +		try {
  +			parser_settings = componentManager.getFeature(PARSER_SETTINGS);  	
  +		}
  +		catch (XMLConfigurationException e){
  +			parser_settings = true;
  +		}
  +        
  +		if (!parser_settings){
  +			// parser settings have not been changed
  +			fValidationManager.addValidationState(fValidationState);
  +			return;
  +		}
  +        	
  +
   
   		// get symbol table. if it's a new one, add symbols to it.
   		SymbolTable symbolTable = (SymbolTable) componentManager.getProperty(SYMBOL_TABLE);
   		if (symbolTable != fSymbolTable) {
  -			fSchemaLoader.setProperty(SYMBOL_TABLE, symbolTable);
   			fSymbolTable = symbolTable;
   		}
   
  @@ -1272,9 +1322,6 @@
   		} catch (XMLConfigurationException e) {
   			fFullChecking = false;
   		}
  -		// the validator will do full checking anyway; the loader should
  -		// not (and in fact cannot) concern itself with this.
  -		fSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, false);
   
   		try {
   			fNormalizeData = componentManager.getFeature(NORMALIZE_DATA);
  @@ -1302,18 +1349,11 @@
   		}
   
   		fEntityResolver = (XMLEntityResolver) componentManager.getProperty(ENTITY_MANAGER);
  -		fSchemaLoader.setEntityResolver(fEntityResolver);
   
   		fValidationManager = (ValidationManager) componentManager.getProperty(VALIDATION_MANAGER);
   		fValidationManager.addValidationState(fValidationState);
   		fValidationState.setSymbolTable(fSymbolTable);
   
  -		fIdConstraint = false;
  -		//reset XSDDescription
  -		fLocationPairs.clear();
  -
  -		// cleanup id table
  -		fValidationState.resetIDTables();
   
   		// get schema location properties
   		try {
  @@ -1324,8 +1364,7 @@
   			fExternalSchemas = null;
   			fExternalNoNamespaceSchema = null;
   		}
  -		fSchemaLoader.setProperty(SCHEMA_LOCATION, fExternalSchemas);
  -		fSchemaLoader.setProperty(SCHEMA_NONS_LOCATION, fExternalNoNamespaceSchema);
  +		
   		// store the external schema locations. they are set when reset is called,
   		// so any other schemaLocation declaration for the same namespace will be
   		// effectively ignored. becuase we choose to take first location hint
  @@ -1342,7 +1381,6 @@
   			fJaxpSchemaSource = null;
   
   		}
  -		fSchemaLoader.setProperty(JAXP_SCHEMA_SOURCE, fJaxpSchemaSource);
   		fResourceIdentifier.clear();
   
   		// clear grammars, and put the one for schema namespace there
  @@ -1351,56 +1389,6 @@
   		} catch (XMLConfigurationException e) {
   			fGrammarPool = null;
   		}
  -		fSchemaLoader.setProperty(XMLGRAMMAR_POOL, fGrammarPool);
  -		// only set useDeclPool to true when the validator invokes the loader,
  -		// and there is no grammar pool. that is, the grammar will never be
  -		// exposed to the application.
  -		fSchemaLoader.setUseDeclPool(fGrammarPool == null);
  -
  -		// Copy the allow-java-encoding feature to the grammar loader.
  -		// REVISIT: what other fetures/properties do we want to copy?
  -		try {
  -			boolean allowJavaEncodings = componentManager.getFeature(ALLOW_JAVA_ENCODINGS);
  -			fSchemaLoader.setFeature(ALLOW_JAVA_ENCODINGS, allowJavaEncodings);
  -		} catch (XMLConfigurationException e) {
  -		}
  -		try {
  -			boolean strictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT_FEATURE);
  -			fSchemaLoader.setFeature(STANDARD_URI_CONFORMANT_FEATURE, strictURI);
  -		} catch (XMLConfigurationException e) {
  -		}
  -
  -		// get continue-after-fatal-error feature
  -		try {
  -			boolean fatalError = componentManager.getFeature(CONTINUE_AFTER_FATAL_ERROR);
  -			fSchemaLoader.setFeature(CONTINUE_AFTER_FATAL_ERROR, fatalError);
  -		} catch (XMLConfigurationException e) {
  -		}
  -
  -		//pass the component manager to the factory..
  -		nodeFactory.reset(componentManager);
  -
  -		// clear grammars, and put the one for schema namespace there
  -		// logic for resetting grammar-related components moved
  -		// to schema loader
  -		fSchemaLoader.reset();
  -
  -		// initialize state
  -		fCurrentElemDecl = null;
  -		fCurrentCM = null;
  -		fCurrCMState = null;
  -		fSkipValidationDepth = -1;
  -		fNFullValidationDepth = -1;
  -		fNNoneValidationDepth = -1;
  -		fElementDepth = -1;
  -		fSubElement = false;
  -
  -		// datatype normalization
  -		fEntityRef = false;
  -		fInCDATA = false;
  -
  -		fMatcherStack.clear();
  -		fBaseURI = null;
   
   		fState4XsiType.setSymbolTable(symbolTable);
   		fState4ApplyDefault.setSymbolTable(symbolTable);
  @@ -1704,7 +1692,7 @@
   				// if a DTD grammar is found, we do the same thing as Dynamic:
   				// if a schema grammar is found, validation is performed;
   				// otherwise, skip the whole document.
  -				fDynamicValidation = true;
  +				fSchemaDynamicValidation = true;
   			} else {
   				// [1] Either schemaType is DTD, and in this case validate/schema is turned off
   				// [2] Validating against XML Schemas only
  @@ -1855,7 +1843,7 @@
   			if (fElementDepth == 0) {
   				// for dynamic validation, skip the whole content,
   				// because no grammar was found.
  -				if (fDynamicValidation) {
  +				if (fDynamicValidation || fSchemaDynamicValidation) {
   					// no schema grammar was found, but it's either dynamic
   					// validation, or another kind of grammar was found (DTD,
   					// for example). The intended behavior here is to skip
  
  
  
  1.6       +1235 -92  xml-xerces/java/src/org/apache/xerces/parsers/XML11Configuration.java
  
  Index: XML11Configuration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/XML11Configuration.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XML11Configuration.java	2 Oct 2003 19:45:42 -0000	1.5
  +++ XML11Configuration.java	7 Nov 2003 00:26:18 -0000	1.6
  @@ -58,43 +58,63 @@
   package org.apache.xerces.parsers;
   
   import java.io.IOException;
  +import java.util.Hashtable;
  +import java.util.Locale;
  +import java.util.Vector;
   
   import org.apache.xerces.impl.Constants;
   import org.apache.xerces.impl.XML11DTDScannerImpl;
   import org.apache.xerces.impl.XML11DocumentScannerImpl;
  -import org.apache.xerces.impl.XML11NamespaceBinder;
   import org.apache.xerces.impl.XML11NSDocumentScannerImpl;
  +import org.apache.xerces.impl.XMLDTDScannerImpl;
  +import org.apache.xerces.impl.XMLDocumentScannerImpl;
   import org.apache.xerces.impl.XMLEntityHandler;
  +import org.apache.xerces.impl.XMLEntityManager;
  +import org.apache.xerces.impl.XMLErrorReporter;
  +import org.apache.xerces.impl.XMLNSDocumentScannerImpl;
   import org.apache.xerces.impl.XMLVersionDetector;
  -
   import org.apache.xerces.impl.dtd.XML11DTDProcessor;
   import org.apache.xerces.impl.dtd.XML11DTDValidator;
   import org.apache.xerces.impl.dtd.XML11NSDTDValidator;
  -
  +import org.apache.xerces.impl.dtd.XMLDTDProcessor;
  +import org.apache.xerces.impl.dtd.XMLDTDValidator;
  +import org.apache.xerces.impl.dtd.XMLNSDTDValidator;
   import org.apache.xerces.impl.dv.DTDDVFactory;
  -
  +import org.apache.xerces.impl.msg.XMLMessageFormatter;
  +import org.apache.xerces.impl.validation.ValidationManager;
   import org.apache.xerces.impl.xs.XMLSchemaValidator;
   import org.apache.xerces.impl.xs.XSMessageFormatter;
  -
  +import org.apache.xerces.util.ParserConfigurationSettings;
   import org.apache.xerces.util.SymbolTable;
  -
  +import org.apache.xerces.xni.XMLDTDContentModelHandler;
  +import org.apache.xerces.xni.XMLDTDHandler;
  +import org.apache.xerces.xni.XMLDocumentHandler;
  +import org.apache.xerces.xni.XMLLocator;
   import org.apache.xerces.xni.XNIException;
   import org.apache.xerces.xni.grammars.XMLGrammarPool;
  +import org.apache.xerces.xni.parser.XMLComponent;
   import org.apache.xerces.xni.parser.XMLComponentManager;
  +import org.apache.xerces.xni.parser.XMLConfigurationException;
  +import org.apache.xerces.xni.parser.XMLDTDScanner;
  +import org.apache.xerces.xni.parser.XMLDocumentScanner;
  +import org.apache.xerces.xni.parser.XMLDocumentSource;
  +import org.apache.xerces.xni.parser.XMLEntityResolver;
  +import org.apache.xerces.xni.parser.XMLErrorHandler;
  +import org.apache.xerces.xni.parser.XMLInputSource;
  +import org.apache.xerces.xni.parser.XMLParserConfiguration;
   
   /**
  - * This class is the configuration used to parse XML 1.1 documents.
  - * It extends the StandardParserConfiguration by making
  - * use of a special scanner which detects the version of the document
  - * being scanned and modifies the pipeline to employ
  - * scanners optimal for the document being scanned.
  + * This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
  + * This is the default Xerces configuration.
    *
  + * @author Elena Litani, IBM
    * @author Neil Graham, IBM
    * @author Michael Glavassevich, IBM
    *
    * @version $Id$
    */
  -public class XML11Configuration extends IntegratedParserConfiguration {
  +public class XML11Configuration extends ParserConfigurationSettings
  +implements XMLParserConfiguration {
   
       //
       // Constants
  @@ -102,11 +122,238 @@
       protected final static String XML11_DATATYPE_VALIDATOR_FACTORY =
           "org.apache.xerces.impl.dv.dtd.XML11DTDDVFactoryImpl";
   
  +    // feature identifiers
  +
  +    /** Feature identifier: warn on duplicate attribute definition. */
  +    protected static final String WARN_ON_DUPLICATE_ATTDEF =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE;
  +
  +    /** Feature identifier: warn on duplicate entity definition. */
  +    protected static final String WARN_ON_DUPLICATE_ENTITYDEF =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ENTITYDEF_FEATURE;
  +
  +    /** Feature identifier: warn on undeclared element definition. */
  +    protected static final String WARN_ON_UNDECLARED_ELEMDEF =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE;
  +
  +    /** Feature identifier: allow Java encodings. */
  +    protected static final String ALLOW_JAVA_ENCODINGS =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
  +
  +    /** Feature identifier: continue after fatal error. */
  +    protected static final String CONTINUE_AFTER_FATAL_ERROR =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
  +
  +    /** Feature identifier: load external DTD. */
  +    protected static final String LOAD_EXTERNAL_DTD =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
  +
  +    /** Feature identifier: notify built-in refereces. */
  +    protected static final String NOTIFY_BUILTIN_REFS =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_BUILTIN_REFS_FEATURE;
  +
  +    /** Feature identifier: notify character refereces. */
  +    protected static final String NOTIFY_CHAR_REFS =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_CHAR_REFS_FEATURE;
  +
  +    /** Feature identifier: expose schema normalized value */
  +    protected static final String NORMALIZE_DATA =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE;
  +
  +    /** Feature identifier: send element default value via characters() */
  +    protected static final String SCHEMA_ELEMENT_DEFAULT =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT;
  +
  +    /** Feature identifier: augment PSVI */
  +    protected static final String SCHEMA_AUGMENT_PSVI =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI;
  +
  +    /** feature identifier: XML Schema validation */
  +    protected static final String XMLSCHEMA_VALIDATION =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
  +
  +    /** feature identifier: XML Schema validation -- full checking */
  +    protected static final String XMLSCHEMA_FULL_CHECKING =
  +        Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
  +        
  +	// feature identifiers
  +
  +	/** Feature identifier: validation. */
  +	protected static final String VALIDATION =
  +		Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
  +    
  +	/** Feature identifier: namespaces. */
  +	protected static final String NAMESPACES =
  +		Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
  +    
  +	/** Feature identifier: external general entities. */
  +	protected static final String EXTERNAL_GENERAL_ENTITIES =
  +		Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
  +    
  +	/** Feature identifier: external parameter entities. */
  +	protected static final String EXTERNAL_PARAMETER_ENTITIES =
  +		Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
  +		
  +	protected static final String PARSER_SETTINGS = 
  +	    Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;	
  +    
  +
  +    // property identifiers
  +   
  +
  +	/** Property identifier: xml string. */
  +	protected static final String XML_STRING = 
  +		Constants.SAX_PROPERTY_PREFIX + Constants.XML_STRING_PROPERTY;
  +
  +	/** Property identifier: symbol table. */
  +	protected static final String SYMBOL_TABLE = 
  +		Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  +
  +	/** Property identifier: error handler. */
  +	protected static final String ERROR_HANDLER = 
  +		Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
  +
  +	/** Property identifier: entity resolver. */
  +	protected static final String ENTITY_RESOLVER = 
  +		Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
  +
  +
  +    /** Property identifier: XML Schema validator. */
  +    protected static final String SCHEMA_VALIDATOR =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;
  +
  +    /** Property identifier: schema location. */
  +    protected static final String SCHEMA_LOCATION =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_LOCATION;
  +
  +    /** Property identifier: no namespace schema location. */
  +    protected static final String SCHEMA_NONS_LOCATION =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION;
  +
  +    // property identifiers
  +
  +    /** Property identifier: error reporter. */
  +    protected static final String ERROR_REPORTER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
  +
  +    /** Property identifier: entity manager. */
  +    protected static final String ENTITY_MANAGER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
  +
  +    /** Property identifier document scanner: */
  +    protected static final String DOCUMENT_SCANNER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
  +
  +    /** Property identifier: DTD scanner. */
  +    protected static final String DTD_SCANNER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
  +
  +    /** Property identifier: grammar pool. */
  +    protected static final String XMLGRAMMAR_POOL =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
  +
  +    /** Property identifier: DTD loader. */
  +    protected static final String DTD_PROCESSOR =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_PROCESSOR_PROPERTY;
  +
  +    /** Property identifier: DTD validator. */
  +    protected static final String DTD_VALIDATOR =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY;
  +
  +    /** Property identifier: namespace binder. */
  +    protected static final String NAMESPACE_BINDER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_BINDER_PROPERTY;
  +
  +    /** Property identifier: datatype validator factory. */
  +    protected static final String DATATYPE_VALIDATOR_FACTORY =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
  +
  +    protected static final String VALIDATION_MANAGER =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
  +
  +    /** Property identifier: JAXP schema language / DOM schema-type. */
  +    protected static final String JAXP_SCHEMA_LANGUAGE =
  +        Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE;
  +
  +    /** Property identifier: JAXP schema source/ DOM schema-location. */
  +    protected static final String JAXP_SCHEMA_SOURCE =
  +        Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
  +
  +    // debugging
  +
  +    /** Set to true and recompile to print exception stack trace. */
  +    protected static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
  +
       // 
       // Data
       //
   
  -    protected XMLVersionDetector fVersionDetector = new XMLVersionDetector();
  +	protected SymbolTable fSymbolTable;
  +    protected XMLInputSource fInputSource;
  +    protected ValidationManager fValidationManager;
  +	protected XMLVersionDetector fVersionDetector;
  +    protected XMLLocator fLocator;
  +	protected Locale fLocale;
  +
  +	/** XML 1.0 Components. */
  +	protected Vector fComponents;
  +    
  +	/** XML 1.1. Components. */
  +	protected Vector fXML11Components = null;
  +	
  +	/** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */
  +	protected Vector fCommonComponents = null;
  +
  +	/** The document handler. */
  +	protected XMLDocumentHandler fDocumentHandler;
  +
  +	/** The DTD handler. */
  +	protected XMLDTDHandler fDTDHandler;
  +
  +	/** The DTD content model handler. */
  +	protected XMLDTDContentModelHandler fDTDContentModelHandler;
  +
  +	/** Last component in the document pipeline */     
  +	protected XMLDocumentSource fLastComponent;
  +
  +    /** 
  +     * True if a parse is in progress. This state is needed because
  +     * some features/properties cannot be set while parsing (e.g.
  +     * validation and namespaces).
  +     */
  +    protected boolean fParseInProgress = false;
  +    
  +    /** fConfigUpdated is set to true if there has been any change to the configuration settings, 
  +     * i.e a feature or a property was changed.
  +     */
  +	protected boolean fConfigUpdated = false;
  +
  +    //
  +    // XML 1.0 components
  +    //
  +
  +    /** The XML 1.0 Datatype validator factory. */
  +    protected DTDDVFactory fDatatypeValidatorFactory;
  +
  +    /** The XML 1.0 Document scanner that does namespace binding. */
  +    protected XMLNSDocumentScannerImpl fNamespaceScanner;
  +    /** The XML 1.0 Non-namespace implementation of scanner */
  +    protected XMLDocumentScannerImpl fNonNSScanner;
  +    /** The XML 1.0 DTD Validator: binds namespaces */
  +    protected XMLDTDValidator fDTDValidator;
  +    /** The XML 1.0 DTD Validator that does not bind namespaces */
  +    protected XMLDTDValidator fNonNSDTDValidator;
  +    /** The XML 1.0 DTD scanner. */
  +    protected XMLDTDScanner fDTDScanner;
  +    /** The XML 1.0 DTD Processor . */
  +    protected XMLDTDProcessor fDTDProcessor;
  +
  +    //
  +    // XML 1.1 components
  +    //
  +
  +    /** The XML 1.1 datatype factory. **/
  +    protected DTDDVFactory fXML11DatatypeFactory = null;
   
       /** The XML 1.1 document scanner that does namespace binding. **/
       protected XML11NSDocumentScannerImpl fXML11NSDocScanner = null;
  @@ -114,23 +361,42 @@
       /** The XML 1.1 document scanner that does not do namespace binding. **/
       protected XML11DocumentScannerImpl fXML11DocScanner = null;
   
  -    /** The XML 1.1 DTD scanner. **/
  -    protected XML11DTDScannerImpl fXML11DTDScanner = null;
  -
       /** The XML 1.1 DTD validator that does namespace binding. **/
       protected XML11NSDTDValidator fXML11NSDTDValidator = null;
   
       /** The XML 1.1 DTD validator that does not do namespace binding. **/
       protected XML11DTDValidator fXML11DTDValidator = null;
   
  +    /** The XML 1.1 DTD scanner. **/
  +    protected XML11DTDScannerImpl fXML11DTDScanner = null;
       /** The XML 1.1 DTD processor. **/
       protected XML11DTDProcessor fXML11DTDProcessor = null;
   
  -    /** The XML 1.1 namespace binder. **/
  -    protected XML11NamespaceBinder fXML11NamespaceBinder = null;
  +    //
  +    // Common components
  +    //
  +
  +    /** Grammar pool. */
  +    protected XMLGrammarPool fGrammarPool;
  +
  +    /** Error reporter. */
  +    protected XMLErrorReporter fErrorReporter;
  +
  +    /** Entity manager. */
  +    protected XMLEntityManager fEntityManager;
  +
  +    /** XML Schema Validator. */
  +    protected XMLSchemaValidator fSchemaValidator;
  +
  +    /** Current scanner */
  +    protected XMLDocumentScanner fCurrentScanner;
  +    /** Current Datatype validator factory. */
  +    protected DTDDVFactory fCurrentDVFactory;
  +    /** Current DTD scanner. */
  +    protected XMLDTDScanner fCurrentDTDScanner;
   
  -    /** The XML 1.1 datatype factory. **/
  -    protected DTDDVFactory fXML11DatatypeFactory = null;
  +
  +    private boolean fInitalized = false;
   
       //
       // Constructors
  @@ -161,8 +427,7 @@
        * @param symbolTable The symbol table to use.
        * @param grammarPool The grammar pool to use.
        */
  -    public XML11Configuration(SymbolTable symbolTable, 
  -                              XMLGrammarPool grammarPool) {
  +    public XML11Configuration(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
           this(symbolTable, grammarPool, null);
       } // <init>(SymbolTable,XMLGrammarPool)
   
  @@ -178,31 +443,368 @@
        * @param grammarPool    The grammar pool to use.
        * @param parentSettings The parent settings.
        */
  -    public XML11Configuration(SymbolTable symbolTable, 
  -                              XMLGrammarPool grammarPool, 
  -                              XMLComponentManager parentSettings) {
  -        super(symbolTable, grammarPool, parentSettings);
  +    public XML11Configuration(
  +        SymbolTable symbolTable,
  +        XMLGrammarPool grammarPool,
  +        XMLComponentManager parentSettings) {
  +		
  +		super(parentSettings);
  +
  +		// create a vector to hold all the components in use
  +		// XML 1.0 specialized components
  +		fComponents = new Vector();
  +		// XML 1.1 specialized components
  +		fXML11Components = new Vector();
  +		// Common components for XML 1.1. and XML 1.0
  +		fCommonComponents = new Vector();
  +
  +		// create storage for recognized features and properties
  +		fRecognizedFeatures = new Vector();
  +		fRecognizedProperties = new Vector();
  +
  +		// create table for features and properties
  +		fFeatures = new Hashtable();
  +		fProperties = new Hashtable();
  +
  +        // add default recognized features
  +        final String[] recognizedFeatures =
  +            {   PARSER_SETTINGS,
  +            	CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
  +				VALIDATION,                 
  +				NAMESPACES,
  +                NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
  +            	// NOTE: These shouldn't really be here but since the XML Schema
  +            	//       validator is constructed dynamically, its recognized
  +            	//       features might not have been set and it would cause a
  +            	//       not-recognized exception to be thrown. -Ac
  +            	XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING, 			
  +				EXTERNAL_GENERAL_ENTITIES,  
  +				EXTERNAL_PARAMETER_ENTITIES,
  +			};
  +        addRecognizedFeatures(recognizedFeatures);
  +		// set state for default features
  +		super.setFeature(VALIDATION, false);
  +		super.setFeature(NAMESPACES, true);
  +		super.setFeature(EXTERNAL_GENERAL_ENTITIES, true);
  +		super.setFeature(EXTERNAL_PARAMETER_ENTITIES, true);
  +		super.setFeature(CONTINUE_AFTER_FATAL_ERROR, false);
  +		super.setFeature(LOAD_EXTERNAL_DTD, true); // from XMLDTDScannerImpl
  +        // set state for default features
  +		super.setFeature(SCHEMA_ELEMENT_DEFAULT, true);
  +		super.setFeature(NORMALIZE_DATA, true);
  +		super.setFeature(SCHEMA_AUGMENT_PSVI, true);
  +		super.setFeature(PARSER_SETTINGS, true);
  +
  +        // add default recognized properties
  +        final String[] recognizedProperties =
  +            {				     
  +				SYMBOL_TABLE,
  +				ERROR_HANDLER,  
  +				ENTITY_RESOLVER,
  +                ERROR_REPORTER,
  +                ENTITY_MANAGER,
  +                DOCUMENT_SCANNER,
  +                DTD_SCANNER,
  +                DTD_PROCESSOR,
  +                DTD_VALIDATOR,
  +				DATATYPE_VALIDATOR_FACTORY,
  +				VALIDATION_MANAGER,
  +				SCHEMA_VALIDATOR,
  +				XML_STRING,
  +                XMLGRAMMAR_POOL, 
  +                JAXP_SCHEMA_SOURCE,
  +                JAXP_SCHEMA_LANGUAGE,                
  +            	// NOTE: These shouldn't really be here but since the XML Schema
  +            	//       validator is constructed dynamically, its recognized
  +            	//       properties might not have been set and it would cause a
  +            	//       not-recognized exception to be thrown. -Ac
  +            	SCHEMA_LOCATION, SCHEMA_NONS_LOCATION, };
  +        addRecognizedProperties(recognizedProperties);
  +		
  +		if (symbolTable == null) {
  +			symbolTable = new SymbolTable();
  +		}
  +		fSymbolTable = symbolTable;
  +		super.setProperty(SYMBOL_TABLE, fSymbolTable);
  +		
  +        fGrammarPool = grammarPool;
  +        if (fGrammarPool != null) {
  +			super.setProperty(XMLGRAMMAR_POOL, fGrammarPool);
  +        }
  +
  +        fEntityManager = new XMLEntityManager();
  +		super.setProperty(ENTITY_MANAGER, fEntityManager);
  +        addCommonComponent(fEntityManager);
  +
  +        fErrorReporter = new XMLErrorReporter();
  +        fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
  +		super.setProperty(ERROR_REPORTER, fErrorReporter);
  +        addCommonComponent(fErrorReporter);
  +
  +        fNamespaceScanner = new XMLNSDocumentScannerImpl();
  +		super.setProperty(DOCUMENT_SCANNER, fNamespaceScanner);
  +        addComponent((XMLComponent) fNamespaceScanner);
  +
  +        fDTDScanner = new XMLDTDScannerImpl();
  +        super.setProperty(DTD_SCANNER, fDTDScanner);
  +        addComponent((XMLComponent) fDTDScanner);
  +
  +        fDTDProcessor = new XMLDTDProcessor();
  +        super.setProperty(DTD_PROCESSOR, fDTDProcessor);
  +        addComponent((XMLComponent) fDTDProcessor);
  +
  +        fDTDValidator = new XMLNSDTDValidator();
  +        super.setProperty(DTD_VALIDATOR, fDTDValidator);
  +        addComponent(fDTDValidator);
  +
  +        fDatatypeValidatorFactory = DTDDVFactory.getInstance();
  +        super.setProperty(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
  +
  +        fValidationManager = new ValidationManager();
  +        super.setProperty(VALIDATION_MANAGER, fValidationManager);
  +        
  +        fVersionDetector = new XMLVersionDetector();
  +        
  +        // add message formatters
  +        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
  +            XMLMessageFormatter xmft = new XMLMessageFormatter();
  +            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
  +            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
  +        }
  +
  +        // set locale
  +        try {
  +            setLocale(Locale.getDefault());
  +        } catch (XNIException e) {
  +            // do nothing
  +            // REVISIT: What is the right thing to do? -Ac
  +        }
  +        
  +		fConfigUpdated = false;
  +
       } // <init>(SymbolTable,XMLGrammarPool)
   
       //
       // Public methods
       //
  -    public boolean parse(boolean complete) throws XNIException, IOException {
  +    /**
  +     * Sets the input source for the document to parse.
  +     *
  +     * @param inputSource The document's input source.
  +     *
  +     * @exception XMLConfigurationException Thrown if there is a 
  +     *                        configuration error when initializing the
  +     *                        parser.
  +     * @exception IOException Thrown on I/O error.
  +     *
  +     * @see #parse(boolean)
  +     */
  +    public void setInputSource(XMLInputSource inputSource)
  +        throws XMLConfigurationException, IOException {
  +
  +        // 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)
  +
  +    /**
  +     * Set the locale to use for messages.
  +     *
  +     * @param locale The locale object to use for localization of messages.
  +     *
  +     * @exception XNIException Thrown if the parser does not support the
  +     *                         specified locale.
  +     */
  +    public void setLocale(Locale locale) throws XNIException {
  +        fLocale = locale;
  +        fErrorReporter.setLocale(locale);
  +    } // setLocale(Locale)
  +	/**
  +	 * Sets the document handler on the last component in the pipeline
  +	 * to receive information about the document.
  +	 * 
  +	 * @param documentHandler   The document handler.
  +	 */
  +	public void setDocumentHandler(XMLDocumentHandler documentHandler) {
  +		fDocumentHandler = documentHandler;
  +		if (fLastComponent != null) {
  +			fLastComponent.setDocumentHandler(fDocumentHandler);
  +			if (fDocumentHandler !=null){
  +				fDocumentHandler.setDocumentSource(fLastComponent);
  +			}
  +		}
  +	} // setDocumentHandler(XMLDocumentHandler)
  +
  +	/** Returns the registered document handler. */
  +	public XMLDocumentHandler getDocumentHandler() {
  +		return fDocumentHandler;
  +	} // getDocumentHandler():XMLDocumentHandler
  +
  +	/**
  +	 * Sets the DTD handler.
  +	 * 
  +	 * @param dtdHandler The DTD handler.
  +	 */
  +	public void setDTDHandler(XMLDTDHandler dtdHandler) {
  +		fDTDHandler = dtdHandler;
  +	} // setDTDHandler(XMLDTDHandler)
  +
  +	/** Returns the registered DTD handler. */
  +	public XMLDTDHandler getDTDHandler() {
  +		return fDTDHandler;
  +	} // getDTDHandler():XMLDTDHandler
  +
  +	/**
  +	 * Sets the DTD content model handler.
  +	 * 
  +	 * @param handler The DTD content model handler.
  +	 */
  +	public void setDTDContentModelHandler(XMLDTDContentModelHandler handler) {
  +		fDTDContentModelHandler = handler;
  +	} // setDTDContentModelHandler(XMLDTDContentModelHandler)
  +
  +	/** Returns the registered DTD content model handler. */
  +	public XMLDTDContentModelHandler getDTDContentModelHandler() {
  +		return fDTDContentModelHandler;
  +	} // getDTDContentModelHandler():XMLDTDContentModelHandler
  +
  +	/**
  +	 * Sets the resolver used to resolve external entities. The EntityResolver
  +	 * interface supports resolution of public and system identifiers.
  +	 *
  +	 * @param resolver The new entity resolver. Passing a null value will
  +	 *                 uninstall the currently installed resolver.
  +	 */
  +	public void setEntityResolver(XMLEntityResolver resolver) {
  +		fProperties.put(ENTITY_RESOLVER, resolver);
  +	} // setEntityResolver(XMLEntityResolver)
  +
  +	/**
  +	 * Return the current entity resolver.
  +	 *
  +	 * @return The current entity resolver, or null if none
  +	 *         has been registered.
  +	 * @see #setEntityResolver
  +	 */
  +	public XMLEntityResolver getEntityResolver() {
  +		return (XMLEntityResolver)fProperties.get(ENTITY_RESOLVER);
  +	} // getEntityResolver():XMLEntityResolver
  +	
  +	/**
  +	 * Allow an application to register an error event handler.
  +	 *
  +	 * <p>If the application does not register an error handler, all
  +	 * error events reported by the SAX parser will be silently
  +	 * ignored; however, normal processing may not continue.  It is
  +	 * highly recommended that all SAX applications implement an
  +	 * error handler to avoid unexpected bugs.</p>
  +	 *
  +	 * <p>Applications may register a new or different handler in the
  +	 * middle of a parse, and the SAX parser must begin using the new
  +	 * handler immediately.</p>
  +	 *
  +	 * @param errorHandler The error handler.
  +	 * @exception java.lang.NullPointerException If the handler 
  +	 *            argument is null.
  +	 * @see #getErrorHandler
  +	 */
  +	public void setErrorHandler(XMLErrorHandler errorHandler) {
  +		fProperties.put(ERROR_HANDLER, errorHandler);
  +	} // setErrorHandler(XMLErrorHandler)
  +
  +	/**
  +	 * Return the current error handler.
  +	 *
  +	 * @return The current error handler, or null if none
  +	 *         has been registered.
  +	 * @see #setErrorHandler
  +	 */
  +	public XMLErrorHandler getErrorHandler() {
  +		// REVISIT: Should this be a property?
  +		return (XMLErrorHandler)fProperties.get(ERROR_HANDLER);
  +	} // getErrorHandler():XMLErrorHandler
  +
  +
  +    /**
  +     * If the application decides to terminate parsing before the xml document
  +     * is fully parsed, the application should call this method to free any
  +     * resource allocated during parsing. For example, close all opened streams.
  +     */
  +    public void cleanup() {
  +        fEntityManager.closeReaders();
  +    }
  +
  +    /**
  +     * Parses the specified input source.
  +     *
  +     * @param source The input source.
  +     *
  +     * @exception XNIException Throws exception on XNI error.
  +     * @exception java.io.IOException Throws exception on i/o error.
  +     */
  +    public void parse(XMLInputSource source) throws XNIException, IOException {
  +
  +        if (fParseInProgress) {
  +            // REVISIT - need to add new error message
  +            throw new XNIException("FWK005 parse may not be called while parsing.");
  +        }
  +        fParseInProgress = true;
  +
  +        try {
  +            setInputSource(source);
  +            parse(true);
  +        } 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 (RuntimeException ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw ex;
  +        } catch (Exception ex) {
  +            if (PRINT_EXCEPTION_STACK_TRACE)
  +                ex.printStackTrace();
  +            throw new XNIException(ex);
  +        } finally {
  +            fParseInProgress = false;
  +            // close all streams opened by xerces
  +            this.cleanup();
  +        }
  +
  +    } // parse(InputSource)
   
  +    public boolean parse(boolean complete) throws XNIException, IOException {
           //
           // reset and configure pipeline and set InputSource.
           if (fInputSource != null) {
               try {
  +				fValidationManager.reset();
                   fVersionDetector.reset(this);
  -                reset();
  +                resetCommon();
   
                   short version = fVersionDetector.determineDocVersion(fInputSource);
                   if (version == Constants.XML_VERSION_1_1) {
  -                    // XML 1.1 pipeline
  +                    initXML11Components();
                       configureXML11Pipeline();
  +                    resetXML11();
  +                } else {
  +                    configurePipeline();
  +                    reset();
                   }
  +                
  +                // mark configuration as fixed
  +                fConfigUpdated = false;
  +
                   // resets and sets the pipeline.
  -                fVersionDetector.startDocumentParsing((XMLEntityHandler) fScanner, version);
  +                fVersionDetector.startDocumentParsing((XMLEntityHandler) fCurrentScanner, version);
                   fInputSource = null;
               } catch (XNIException ex) {
                   if (PRINT_EXCEPTION_STACK_TRACE)
  @@ -224,7 +826,7 @@
           }
   
           try {
  -            return fScanner.scanDocument(complete);
  +            return fCurrentScanner.scanDocument(complete);
           } catch (XNIException ex) {
               if (PRINT_EXCEPTION_STACK_TRACE)
                   ex.printStackTrace();
  @@ -244,28 +846,170 @@
           }
   
       } // parse(boolean):boolean
  +    
  +	/**
  +	 * Set the state of a feature.
  +	 *
  +	 * Set the state of any feature in a SAX2 parser.  The parser
  +	 * might not recognize the feature, and if it does recognize
  +	 * it, it might not be able to fulfill the request.
  +	 *
  +	 * @param featureId The unique identifier (URI) of the feature.
  +	 * @param state The requested state of the feature (true or false).
  +	 *
  +	 * @exception org.apache.xerces.xni.parser.XMLConfigurationException If the
  +	 *            requested feature is not known.
  +	 */
  +	public void setFeature(String featureId, boolean state)
  +		throws XMLConfigurationException {
  +		fConfigUpdated = true;
  +		// forward to every XML 1.0 component
  +		int count = fComponents.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fComponents.elementAt(i);
  +			c.setFeature(featureId, state);
  +		}
  +		// forward it to common components
  +		count = fCommonComponents.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fCommonComponents.elementAt(i);
  +			c.setFeature(featureId, state);
  +		}
  +				
  +		// forward to every XML 1.1 component
  +		count = fXML11Components.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fXML11Components.elementAt(i);
  +			try{            
  +				c.setFeature(featureId, state);
  +			}
  +			catch (Exception e){
  +				// no op
  +			}
  +		}
  +		// save state if noone "objects"
  +		super.setFeature(featureId, state);
  +
  +	} // setFeature(String,boolean)
  +	
  +	/**
  +	 * setProperty
  +	 * 
  +	 * @param propertyId 
  +	 * @param value 
  +	 */
  +	public void setProperty(String propertyId, Object value)
  +		throws XMLConfigurationException {
  +		fConfigUpdated = true;
  +		// forward to every XML 1.0 component
  +		int count = fComponents.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fComponents.elementAt(i);
  +			c.setProperty(propertyId, value);
  +		}
  +		// forward it to every common Component
  +		count = fCommonComponents.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fCommonComponents.elementAt(i);
  +			c.setProperty(propertyId, value);
  +		}
  +		// forward it to every XML 1.1 component
  +		count = fXML11Components.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fXML11Components.elementAt(i);
  +			try{			
  +				c.setProperty(propertyId, value);
  +			}
  +			catch (Exception e){
  +				// ignore it
  +			}
  +		}
  +
  +		// store value if noone "objects"
  +		super.setProperty(propertyId, value);
  +
  +	} // setProperty(String,Object)
  +    
  +
  +	/** Returns the locale. */
  +	public Locale getLocale() {
  +		return fLocale;
  +	} // getLocale():Locale
  +	
  +	/**
  +	 * reset all XML 1.0 components before parsing and namespace context
  +	 */
  +	protected void reset() throws XNIException {
  +		// reset every component
  +		int count = fComponents.size();
  +		if (fConfigUpdated){
  +			super.setFeature(PARSER_SETTINGS, true);
  +		}
  +		else {
  +			super.setFeature(PARSER_SETTINGS, false);
  +		}
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fComponents.elementAt(i);
  +			c.reset(this);
  +		}
  +
  +	} // reset()
  +    
  +	/**
  +	 * reset all common components before parsing
  +	 */
  +	protected void resetCommon() throws XNIException {
  +		
  +		if (fConfigUpdated){
  +			super.setFeature(PARSER_SETTINGS, true);
  +		}
  +		else {
  +			super.setFeature(PARSER_SETTINGS, false);
  +		}
  +		// reset common components
  +		int count = fCommonComponents.size();
  +		for (int i = 0; i < count; i++) {
  +			XMLComponent c = (XMLComponent) fCommonComponents.elementAt(i);
  +			c.reset(this);
  +		}
  +
  +	} // resetCommon()
  +    
  +    
  +	/**
  +	 * reset all components before parsing and namespace context
  +	 */
  +	protected void resetXML11() throws XNIException {
  +		if (fConfigUpdated){
  +			super.setFeature(PARSER_SETTINGS, true);
  +		}
  +		else {
  +			super.setFeature(PARSER_SETTINGS, false);
  +		}
  +		// reset every component
  +		int count = fXML11Components.size();
  +		for (int i = 0; i < count; i++) {			
  +			XMLComponent c = (XMLComponent) fXML11Components.elementAt(i);
  +			c.reset(this);
  +		}
  +
  +	} // resetXML11()
  +
   
       /**
        *  Configures the XML 1.1 pipeline. 
        *  Note: this method also resets the new XML11 components.
        */
       protected void configureXML11Pipeline() {
  -
  -        // create datatype factory
  -        if (fXML11DatatypeFactory == null) {
  -            fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);
  +        if (fCurrentDVFactory != fXML11DatatypeFactory) {
  +            fCurrentDVFactory = fXML11DatatypeFactory;
  +            setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory);
           }
  -        setProperty(DATATYPE_VALIDATOR_FACTORY, fXML11DatatypeFactory);
  -
  -        // setup XML 1.1 DTD pipeline
  -        if (fXML11DTDScanner == null) {
  -            fXML11DTDScanner = new XML11DTDScannerImpl();
  +        if (fCurrentDTDScanner != fXML11DTDScanner) {
  +            fCurrentDTDScanner = fXML11DTDScanner;
  +            setProperty(DTD_SCANNER, fCurrentDTDScanner);
  +			setProperty(DTD_PROCESSOR, fXML11DTDProcessor);
           }
  -        if (fXML11DTDProcessor == null) {
  -            fXML11DTDProcessor = new XML11DTDProcessor();
  -        }
  -        fProperties.put(DTD_SCANNER, fXML11DTDScanner);
  -        fProperties.put(DTD_PROCESSOR, fXML11DTDProcessor);
   
           fXML11DTDScanner.setDTDHandler(fXML11DTDProcessor);
           fXML11DTDProcessor.setDTDSource(fXML11DTDScanner);
  @@ -283,28 +1027,14 @@
   
           // setup XML 1.1 document pipeline
           if (fFeatures.get(NAMESPACES) == Boolean.TRUE) {
  -            // REVISIT: Do we still need the namespace binder in the
  -            // configuration? It doesn't appear that any other
  -            // component uses it. - mrglavas
  -            if (fXML11NamespaceBinder == null) {
  -                fXML11NamespaceBinder = new XML11NamespaceBinder();
  -            }
  -            fProperties.put(NAMESPACE_BINDER, fXML11NamespaceBinder);
  -
  -            if (fXML11NSDocScanner == null) {
  -                fXML11NSDocScanner = new XML11NSDocumentScannerImpl();
  +            if (fCurrentScanner != fXML11NSDocScanner) {
  +                fCurrentScanner = fXML11NSDocScanner;
  +                setProperty(DOCUMENT_SCANNER, fXML11NSDocScanner);
  +                setProperty(DTD_VALIDATOR, fXML11NSDTDValidator);
               }
  -            fScanner = fXML11NSDocScanner;
  -            fProperties.put(DOCUMENT_SCANNER, fXML11NSDocScanner);
  -
  -            if (fXML11NSDTDValidator == null) {
  -                fXML11NSDTDValidator = new XML11NSDTDValidator();
  -            }
  -            fProperties.put(DTD_VALIDATOR, fXML11NSDTDValidator);
   
               fXML11NSDocScanner.setDTDValidator(fXML11NSDTDValidator);
               fXML11NSDocScanner.setDocumentHandler(fXML11NSDTDValidator);
  -
               fXML11NSDTDValidator.setDocumentSource(fXML11NSDocScanner);
               fXML11NSDTDValidator.setDocumentHandler(fDocumentHandler);
   
  @@ -313,51 +1043,31 @@
               }
               fLastComponent = fXML11NSDTDValidator;
   
  -            // Reset namespace pipeline components.
  -            fXML11NSDocScanner.reset(this);
  -            fXML11NSDTDValidator.reset(this);
  -            fXML11NamespaceBinder.reset(this);
  -            
           } else {
  -            if (fXML11DocScanner == null) {
  -                fXML11DocScanner = new XML11DocumentScannerImpl();
  +            if (fCurrentScanner != fXML11DocScanner) {
  +                fCurrentScanner = fXML11DocScanner;
  +                setProperty(DOCUMENT_SCANNER, fXML11DocScanner);
  +                setProperty(DTD_VALIDATOR, fXML11DTDValidator);
               }
  -            fScanner = fXML11DocScanner;
  -            fProperties.put(DOCUMENT_SCANNER, fXML11DocScanner);
  -
  -            if (fXML11DTDValidator == null) {
  -                fXML11DTDValidator = new XML11DTDValidator();
  -            }
  -            fProperties.put(DTD_VALIDATOR, fXML11DTDValidator);
  -
               fXML11DocScanner.setDocumentHandler(fXML11DTDValidator);
  -            
               fXML11DTDValidator.setDocumentSource(fXML11DocScanner);
               fXML11DTDValidator.setDocumentHandler(fDocumentHandler);
  -            
  +
               if (fDocumentHandler != null) {
                   fDocumentHandler.setDocumentSource(fXML11DTDValidator);
               }
               fLastComponent = fXML11DTDValidator;
  -            
  -            // Reset no namespace pipeline components.
  -            fXML11DocScanner.reset(this);
  -            fXML11DTDValidator.reset(this);
           }
  -        
  -        // Reset DTD pipeline components.
  -        fXML11DTDScanner.reset(this);
  -        fXML11DTDProcessor.reset(this);
   
           // setup document pipeline
           if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) {
               // 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);
  +                setProperty(SCHEMA_VALIDATOR, fSchemaValidator);
  +				addCommonComponent(fSchemaValidator);
  +				fSchemaValidator.reset(this);
                   // add schema message formatter
                   if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
                       XSMessageFormatter xmft = new XSMessageFormatter();
  @@ -374,6 +1084,439 @@
               fLastComponent = fSchemaValidator;
           }
   
  +    } // configureXML11Pipeline()
  +
  +    /** Configures the pipeline. */
  +    protected void configurePipeline() {
  +        if (fCurrentDVFactory != fDatatypeValidatorFactory) {
  +            fCurrentDVFactory = fDatatypeValidatorFactory;
  +            // use XML 1.0 datatype library
  +            setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory);
  +        }
  +
  +        // setup DTD pipeline
  +        if (fCurrentDTDScanner != fDTDScanner) {
  +			fCurrentDTDScanner = fDTDScanner;
  +            setProperty(DTD_SCANNER, fCurrentDTDScanner);
  +            setProperty(DTD_PROCESSOR, fDTDProcessor);
  +            fDTDScanner.setDTDHandler(fDTDProcessor);
  +            fDTDProcessor.setDTDSource(fDTDScanner);
  +            fDTDProcessor.setDTDHandler(fDTDHandler);
  +            if (fDTDHandler != null) {
  +                 fDTDHandler.setDTDSource(fDTDProcessor);
  +            }
  +
  +            fDTDScanner.setDTDContentModelHandler(fDTDProcessor);
  +            fDTDProcessor.setDTDContentModelSource(fDTDScanner);
  +            fDTDProcessor.setDTDContentModelHandler(fDTDContentModelHandler);
  +            if (fDTDContentModelHandler != null) {
  +                fDTDContentModelHandler.setDTDContentModelSource(fDTDProcessor);
  +            }            
  +        }
  +
  +        // setup document pipeline
  +        if (fFeatures.get(NAMESPACES) == Boolean.TRUE) {
  +            if (fCurrentScanner != fNamespaceScanner) {
  +                fCurrentScanner = fNamespaceScanner;
  +                setProperty(DOCUMENT_SCANNER, fNamespaceScanner);
  +                setProperty(DTD_VALIDATOR, fDTDValidator);
  +            }
  +            fNamespaceScanner.setDTDValidator(fDTDValidator);
  +            fNamespaceScanner.setDocumentHandler(fDTDValidator);
  +            fDTDValidator.setDocumentSource(fNamespaceScanner);
  +            fDTDValidator.setDocumentHandler(fDocumentHandler);
  +            if (fDocumentHandler != null) {
  +                fDocumentHandler.setDocumentSource(fDTDValidator);
  +            }
  +            fLastComponent = fDTDValidator;
  +        } else {
  +            // create components
  +            if (fNonNSScanner == null) {
  +                fNonNSScanner = new XMLDocumentScannerImpl();
  +                fNonNSDTDValidator = new XMLDTDValidator();
  +                // add components
  +                addComponent((XMLComponent) fNonNSScanner);
  +                addComponent((XMLComponent) fNonNSDTDValidator);
  +            }
  +            if (fCurrentScanner != fNonNSScanner) {
  +                fCurrentScanner = fNonNSScanner;
  +                setProperty(DOCUMENT_SCANNER, fNonNSScanner);
  +                setProperty(DTD_VALIDATOR, fNonNSDTDValidator);
  +            }
  +
  +            fNonNSScanner.setDocumentHandler(fNonNSDTDValidator);
  +            fNonNSDTDValidator.setDocumentSource(fNonNSScanner);
  +            fNonNSDTDValidator.setDocumentHandler(fDocumentHandler);
  +            if (fDocumentHandler != null) {
  +                fDocumentHandler.setDocumentSource(fNonNSDTDValidator);
  +            }
  +            fLastComponent = fNonNSDTDValidator;
  +        }
  +
  +        // add XML Schema validator if needed
  +        if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) {
  +            // If schema validator was not in the pipeline insert it.
  +            if (fSchemaValidator == null) {
  +                fSchemaValidator = new XMLSchemaValidator();
  +                // add schema component
  +                setProperty(SCHEMA_VALIDATOR, fSchemaValidator);
  +                addCommonComponent(fSchemaValidator);
  +				fSchemaValidator.reset(this);
  +                // add schema message formatter
  +                if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
  +                    XSMessageFormatter xmft = new XSMessageFormatter();
  +                    fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);
  +                }
  +
  +            }
  +            fLastComponent.setDocumentHandler(fSchemaValidator);
  +            fSchemaValidator.setDocumentSource(fLastComponent);
  +            fSchemaValidator.setDocumentHandler(fDocumentHandler);
  +            if (fDocumentHandler != null) {
  +                fDocumentHandler.setDocumentSource(fSchemaValidator);
  +            }
  +            fLastComponent = fSchemaValidator;
  +        }
       } // configurePipeline()
  +
  +
  +    // features and properties
  +
  +    /**
  +     * Check a feature. If feature is know and supported, this method simply
  +     * returns. Otherwise, the appropriate exception is thrown.
  +     *
  +     * @param featureId The unique identifier (URI) of the feature.
  +     *
  +     * @throws XMLConfigurationException Thrown for configuration error.
  +     *                                   In general, components should
  +     *                                   only throw this exception if
  +     *                                   it is <strong>really</strong>
  +     *                                   a critical error.
  +     */
  +    protected void checkFeature(String featureId) throws XMLConfigurationException {
  +
  +        //
  +        // Xerces Features
  +        //
  +
  +        if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
  +            String feature = featureId.substring(Constants.XERCES_FEATURE_PREFIX.length());
  +            //
  +            // http://apache.org/xml/features/validation/dynamic
  +            //   Allows the parser to validate a document only when it
  +            //   contains a grammar. Validation is turned on/off based
  +            //   on each document instance, automatically.
  +            //
  +            if (feature.equals(Constants.DYNAMIC_VALIDATION_FEATURE)) {
  +                return;
  +            }
  +
  +            //
  +            // http://apache.org/xml/features/validation/default-attribute-values
  +            //
  +            if (feature.equals(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
  +                // REVISIT
  +                short type = XMLConfigurationException.NOT_SUPPORTED;
  +                throw new XMLConfigurationException(type, featureId);
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/default-attribute-values
  +            //
  +            if (feature.equals(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
  +                // REVISIT
  +                short type = XMLConfigurationException.NOT_SUPPORTED;
  +                throw new XMLConfigurationException(type, featureId);
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
  +            //
  +            if (feature.equals(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
  +                return;
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
  +            //
  +            if (feature.equals(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
  +                return;
  +            }
  +
  +            //
  +            // http://apache.org/xml/features/validation/default-attribute-values
  +            //
  +            if (feature.equals(Constants.VALIDATE_DATATYPES_FEATURE)) {
  +                short type = XMLConfigurationException.NOT_SUPPORTED;
  +                throw new XMLConfigurationException(type, featureId);
  +            }
  +            
  +			 //
  +			 // http://apache.org/xml/features/validation/schema
  +			 //   Lets the user turn Schema validation support on/off.
  +			 //
  +			 if (feature.equals(Constants.SCHEMA_VALIDATION_FEATURE)) {
  +				 return;
  +			 }
  +			 // activate full schema checking
  +			 if (feature.equals(Constants.SCHEMA_FULL_CHECKING)) {
  +				 return;
  +			 }
  +			 // Feature identifier: expose schema normalized value 
  +			 //  http://apache.org/xml/features/validation/schema/normalized-value
  +			 if(feature.equals(Constants.SCHEMA_NORMALIZED_VALUE)) {
  +				 return;
  +			 } 
  +			 // Feature identifier: send element default value via characters() 
  +			 // http://apache.org/xml/features/validation/schema/element-default
  +			 if(feature.equals(Constants.SCHEMA_ELEMENT_DEFAULT)) {
  +				 return;
  +			 }
  +
  +        }
  +
  +        //
  +        // Not recognized
  +        //
  +
  +        super.checkFeature(featureId);
  +
  +    } // checkFeature(String)
  +
  +    /**
  +     * Check a property. If the property is know and supported, this method
  +     * simply returns. Otherwise, the appropriate exception is thrown.
  +     *
  +     * @param propertyId The unique identifier (URI) of the property
  +     *                   being set.
  +     *
  +     * @throws XMLConfigurationException Thrown for configuration error.
  +     *                                   In general, components should
  +     *                                   only throw this exception if
  +     *                                   it is <strong>really</strong>
  +     *                                   a critical error.
  +     */
  +    protected void checkProperty(String propertyId) throws XMLConfigurationException {
  +
  +        //
  +        // Xerces Properties
  +        //
  +
  +        if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
  +            String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
  +            if (property.equals(Constants.DTD_SCANNER_PROPERTY)) {
  +                return;
  +            }
  +			if (property.equals(Constants.SCHEMA_LOCATION)) {
  +				return;
  +			}
  +			if (property.equals(Constants.SCHEMA_NONS_LOCATION)) {
  +				return;
  +			}
  +        }
  +        
  +		if (propertyId.startsWith(Constants.JAXP_PROPERTY_PREFIX)) {
  +			String property =
  +				propertyId.substring(Constants.JAXP_PROPERTY_PREFIX.length());
  +			if (property.equals(Constants.SCHEMA_SOURCE)) {
  +				return;
  +			}
  +		}
  +		
  +		// special cases
  +		if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
  +			String property =
  +				propertyId.substring(Constants.SAX_PROPERTY_PREFIX.length());
  +			//
  +			// http://xml.org/sax/properties/xml-string
  +			// Value type: String
  +			// Access: read-only
  +			//   Get the literal string of characters associated with the
  +			//   current event.  If the parser recognises and supports this
  +			//   property but is not currently parsing text, it should return
  +			//   null (this is a good way to check for availability before the
  +			//   parse begins).
  +			//
  +			if (property.equals(Constants.XML_STRING_PROPERTY)) {
  +				// REVISIT - we should probably ask xml-dev for a precise
  +				// definition of what this is actually supposed to return, and
  +				// in exactly which circumstances.
  +				short type = XMLConfigurationException.NOT_SUPPORTED;
  +				throw new XMLConfigurationException(type, propertyId);
  +			}
  +		}
  +
  +        //
  +        // Not recognized
  +        //
  +
  +        super.checkProperty(propertyId);
  +
  +    } // checkProperty(String)
  +
  +
  +	/** 
  +	 * Adds a component to the parser configuration. This method will
  +	 * also add all of the component's recognized features and properties
  +	 * to the list of default recognized features and properties.
  +	 *
  +	 * @param component The component to add.
  +	 */
  +	protected void addComponent(XMLComponent component) {
  +		//System.out.println("==>Adding XML 1.0: "+component);
  +		// don't add a component more than once
  +		if (fComponents.contains(component)) {
  +			return;
  +		}
  +		fComponents.addElement(component);
  +
  +		// register component's recognized features
  +		String[] recognizedFeatures = component.getRecognizedFeatures();
  +		addRecognizedFeatures(recognizedFeatures);
  +        
  +		// register component's recognized properties
  +		String[] recognizedProperties = component.getRecognizedProperties();
  +		addRecognizedProperties(recognizedProperties);
  +
  +		// set default values
  +		if (recognizedFeatures != null) {
  +			for (int i = 0; i < recognizedFeatures.length; i++) {
  +				String featureId = recognizedFeatures[i];
  +				Boolean state = component.getFeatureDefault(featureId);
  +				if (state != null) {
  +					super.setFeature(featureId, state.booleanValue());
  +				}
  +			}
  +		}
  +		if (recognizedProperties != null) {
  +			for (int i = 0; i < recognizedProperties.length; i++) {
  +				String propertyId = recognizedProperties[i];
  +				Object value = component.getPropertyDefault(propertyId);
  +				if (value != null) {
  +					super.setProperty(propertyId, value);
  +				}
  +			}
  +		}
  +
  +	} // addComponent(XMLComponent)
  +    
  +	/** 
  +	 * Adds common component to the parser configuration. This method will
  +	 * also add all of the component's recognized features and properties
  +	 * to the list of default recognized features and properties.
  +	 *
  +	 * @param component The component to add.
  +	 */
  +	protected void addCommonComponent(XMLComponent component) {
  +		// don't add a component more than once
  +		if (fCommonComponents.contains(component)) {
  +			return;
  +		}
  +		fCommonComponents.addElement(component);
  +
  +		// register component's recognized features
  +		String[] recognizedFeatures = component.getRecognizedFeatures();
  +		addRecognizedFeatures(recognizedFeatures);
  +        
  +		// register component's recognized properties
  +		String[] recognizedProperties = component.getRecognizedProperties();
  +		addRecognizedProperties(recognizedProperties);
  +
  +		// set default values
  +		if (recognizedFeatures != null) {
  +			for (int i = 0; i < recognizedFeatures.length; i++) {
  +				String featureId = recognizedFeatures[i];
  +				Boolean state = component.getFeatureDefault(featureId);
  +				if (state != null) {
  +					super.setFeature(featureId, state.booleanValue());
  +				}
  +			}
  +		}
  +		if (recognizedProperties != null) {
  +			for (int i = 0; i < recognizedProperties.length; i++) {
  +				String propertyId = recognizedProperties[i];
  +				Object value = component.getPropertyDefault(propertyId);
  +				if (value != null) {
  +					super.setProperty(propertyId, value);
  +				}
  +			}
  +		}
  +
  +	} // addCommonComponent(XMLComponent)
  +	
  +	/** 
  +	 * Adds an XML 1.1 component to the parser configuration. This method will
  +	 * also add all of the component's recognized features and properties
  +	 * to the list of default recognized features and properties.
  +	 *
  +	 * @param component The component to add.
  +	 */
  +	protected void addXML11Component(XMLComponent component) {
  +		//System.out.println("Adding XML 1.1: " + component);
  +		// don't add a component more than once
  +		if (fXML11Components.contains(component)) {
  +			return;
  +		}
  +		fXML11Components.addElement(component);
  +
  +		// register component's recognized features
  +		String[] recognizedFeatures = component.getRecognizedFeatures();
  +		addRecognizedFeatures(recognizedFeatures);
  +        
  +		// register component's recognized properties
  +		String[] recognizedProperties = component.getRecognizedProperties();
  +		addRecognizedProperties(recognizedProperties);
  +
  +		// set default values
  +		if (recognizedFeatures != null) {
  +			for (int i = 0; i < recognizedFeatures.length; i++) {
  +				String featureId = recognizedFeatures[i];
  +				Boolean state = component.getFeatureDefault(featureId);
  +				if (state != null) {
  +					checkFeature(featureId);
  +					fFeatures.put(featureId, state);
  +				}
  +			}
  +		}
  +		if (recognizedProperties != null) {
  +			for (int i = 0; i < recognizedProperties.length; i++) {
  +				String propertyId = recognizedProperties[i];
  +				Object value = component.getPropertyDefault(propertyId);
  +				if (value != null) {
  +					checkProperty(propertyId);
  +					fProperties.put(propertyId, value);
  +				}
  +			}
  +		}
  +
  +	} // addXML11Component(XMLComponent)
  +
  +
  +    private void initXML11Components() {
  +        if (!fInitalized) {
  +
  +            // create datatype factory
  +            fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);
  +
  +            // setup XML 1.1 DTD pipeline
  +            fXML11DTDScanner = new XML11DTDScannerImpl();
  +            addXML11Component(fXML11DTDScanner);
  +            fXML11DTDProcessor = new XML11DTDProcessor();
  +            addXML11Component(fXML11DTDProcessor);
  +
  +            // setup XML 1.1. document pipeline
  +            fXML11NSDocScanner = new XML11NSDocumentScannerImpl();
  +            addXML11Component(fXML11NSDocScanner);
  +            fXML11NSDTDValidator = new XML11NSDTDValidator();
  +            addXML11Component(fXML11NSDTDValidator);
  +
  +            // non namespace document pipeline
  +            fXML11DocScanner = new XML11DocumentScannerImpl();
  +            addXML11Component(fXML11DocScanner);
  +            fXML11DTDValidator = new XML11DTDValidator();
  +            addXML11Component(fXML11DTDValidator);
  +            
  +            if (fSchemaValidator != null)
  +				addXML11Component(fSchemaValidator);
  +        }
  +    }
   
   } // class XML11Configuration
  
  
  

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