You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/02/15 17:00:31 UTC

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

sandygao    02/02/15 08:00:30

  Modified:    java/src/org/apache/xerces/impl/dtd AbstractDTDGrammar.java
                        DTDGrammar.java XMLDTDValidator.java
                        XMLSimpleType.java
               java/src/org/apache/xerces/impl/dv DTDDVFactory.java
                        DatatypeValidator.java
               java/src/org/apache/xerces/impl/dv/dtd
                        ENTITYDatatypeValidator.java
                        IDDatatypeValidator.java
                        IDREFDatatypeValidator.java
                        ListDatatypeValidator.java
                        NMTOKENDatatypeValidator.java
                        NOTATIONDatatypeValidator.java
                        StringDatatypeValidator.java
               java/src/org/apache/xerces/impl/dv/xs EntityDV.java
               java/src/org/apache/xerces/impl/msg XMLMessages.properties
               java/src/org/apache/xerces/impl/validation
                        ValidationManager.java ValidationState.java
               java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
               java/src/org/apache/xerces/parsers
                        StandardParserConfiguration.java
                        XMLGrammarParser.java
  Added:       java/src/org/apache/xerces/impl/dv/dtd DTDDVFactoryImpl.java
  Removed:     java/src/org/apache/xerces/impl/dv/dtd
                        AbstractDatatypeValidator.java
                        DatatypeMessageProvider.java DatatypeValidator.java
                        DatatypeValidatorFactory.java
                        DatatypeValidatorFactoryImpl.java
                        InvalidDatatypeFacetException.java
                        InvalidDatatypeValueException.java
                        StatefullDatatypeValidator.java
  Log:
  Update DTD datatypes to use the new DV interfaces.
  
  Revision  Changes    Path
  1.8       +8 -8      xml-xerces/java/src/org/apache/xerces/impl/dtd/AbstractDTDGrammar.java
  
  Index: AbstractDTDGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/AbstractDTDGrammar.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractDTDGrammar.java	9 Feb 2002 20:55:21 -0000	1.7
  +++ AbstractDTDGrammar.java	15 Feb 2002 16:00:28 -0000	1.8
  @@ -74,7 +74,7 @@
   import org.apache.xerces.impl.dtd.models.MixedContentModel;
   import org.apache.xerces.impl.dtd.models.SimpleContentModel;
   import org.apache.xerces.impl.validation.EntityState;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidator;
  +import org.apache.xerces.impl.dv.DatatypeValidator;
   import org.apache.xerces.impl.dtd.models.ContentModelValidator;
   import org.apache.xerces.util.SymbolTable;
   
  @@ -104,7 +104,7 @@
    * @author Eric Ye, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: AbstractDTDGrammar.java,v 1.7 2002/02/09 20:55:21 neilg Exp $
  + * @version $Id: AbstractDTDGrammar.java,v 1.8 2002/02/15 16:00:28 sandygao Exp $
    */
   public abstract class AbstractDTDGrammar implements EntityState, Grammar {
   
  @@ -279,8 +279,8 @@
       /** Default constructor. */
       protected AbstractDTDGrammar(SymbolTable symbolTable) {
           fSymbolTable = symbolTable;
  -	// are there really situations in which this is a good idea???  - NG
  -	fGrammarDescription = new XMLDTDDescription();
  +        // are there really situations in which this is a good idea???  - NG
  +        fGrammarDescription = new XMLDTDDescription();
       } // <init>(SymbolTable)
   
       // Grammar methods
  @@ -633,7 +633,7 @@
           notationDecl.setValues(fNotationName[chunk][index], 
                                  fNotationPublicId[chunk][index],
                                  fNotationSystemId[chunk][index],
  -			       fNotationBaseSystemId[chunk][index]);
  +                               fNotationBaseSystemId[chunk][index]);
   
           return true;
   
  @@ -1439,12 +1439,12 @@
                   nodeRet = new CMUniOp( contentSpec.type, buildSyntaxTree(leftNode, contentSpec));
               } 
               else if (contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE
  -		       || contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE
  -		       || contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE) {
  +                       || contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ZERO_OR_ONE
  +                       || contentSpec.type == XMLContentSpec.CONTENTSPECNODE_ONE_OR_MORE) {
                   nodeRet = new CMUniOp(contentSpec.type, buildSyntaxTree(leftNode, contentSpec));
               } 
               else {
  -		        throw new RuntimeException("ImplementationMessages.VAL_CST");
  +                        throw new RuntimeException("ImplementationMessages.VAL_CST");
               }
           }
           // And return our new node for this level
  
  
  
  1.12      +7 -8      xml-xerces/java/src/org/apache/xerces/impl/dtd/DTDGrammar.java
  
  Index: DTDGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/DTDGrammar.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DTDGrammar.java	29 Jan 2002 20:44:02 -0000	1.11
  +++ DTDGrammar.java	15 Feb 2002 16:00:29 -0000	1.12
  @@ -62,7 +62,7 @@
   
   import org.apache.xerces.impl.XMLErrorReporter;
   import org.apache.xerces.impl.msg.XMLMessageFormatter;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactory;
  +import org.apache.xerces.impl.dv.DTDDVFactory;
   import org.apache.xerces.impl.dtd.AbstractDTDGrammar;
   import org.apache.xerces.impl.dtd.models.ContentModelValidator;
   import org.apache.xerces.impl.dtd.XMLElementDecl;
  @@ -71,8 +71,7 @@
   import org.apache.xerces.impl.dtd.XMLEntityDecl;
   import org.apache.xerces.impl.dtd.XMLSimpleType;
   import org.apache.xerces.impl.dtd.XMLContentSpec;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactoryImpl;
  +import org.apache.xerces.impl.dv.DatatypeValidator;
   import org.apache.xerces.util.SymbolTable;
   
   import org.apache.xerces.xni.Augmentations;
  @@ -95,7 +94,7 @@
    * @author Jeffrey Rodriguez, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: DTDGrammar.java,v 1.11 2002/01/29 20:44:02 neilg Exp $
  + * @version $Id: DTDGrammar.java,v 1.12 2002/02/15 16:00:29 sandygao Exp $
    */
   public class DTDGrammar
       extends AbstractDTDGrammar
  @@ -127,7 +126,7 @@
       //
   
       /** Datatype validator factory. */
  -    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
  +    protected DTDDVFactory fDatatypeValidatorFactory;
   
       /** Current element index. */
       protected int fCurrentElementIndex;
  @@ -224,7 +223,7 @@
       //
   
       /** Sets the datatype validator factory. */
  -    public void setDatatypeValidatorFactory(DatatypeValidatorFactory factory) {
  +    public void setDatatypeValidatorFactory(DTDDVFactory factory) {
           fDatatypeValidatorFactory = factory;
       }
   
  @@ -524,8 +523,8 @@
           //Get Grammar index to grammar array
           int elementIndex       = getElementDeclIndex( elementName, -1 );
           
  -	//return, when more than one definition is provided for the same attribute of given element type
  -	//only the first declaration is binding and later declarations are ignored
  +        //return, when more than one definition is provided for the same attribute of given element type
  +        //only the first declaration is binding and later declarations are ignored
           if (getAttributeDeclIndex(elementIndex, attributeName) != -1) {
               return;
           }
  
  
  
  1.18      +89 -123   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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XMLDTDValidator.java	29 Jan 2002 20:44:02 -0000	1.17
  +++ XMLDTDValidator.java	15 Feb 2002 16:00:29 -0000	1.18
  @@ -60,20 +60,14 @@
   import org.apache.xerces.impl.Constants;
   import org.apache.xerces.impl.XMLErrorReporter;
   import org.apache.xerces.impl.validation.ValidationManager;
  +import org.apache.xerces.impl.validation.ValidationState;
   import org.apache.xerces.impl.msg.XMLMessageFormatter;
   
   import org.apache.xerces.impl.validation.EntityState;
   import org.apache.xerces.impl.dtd.models.ContentModelValidator;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactory;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactoryImpl;
  -import org.apache.xerces.impl.dv.dtd.ENTITYDatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.IDDatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.IDREFDatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.ListDatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.NOTATIONDatatypeValidator;
  -import org.apache.xerces.impl.dv.dtd.InvalidDatatypeFacetException;
  -import org.apache.xerces.impl.dv.dtd.InvalidDatatypeValueException;
  +import org.apache.xerces.impl.dv.DatatypeValidator;
  +import org.apache.xerces.impl.dv.DTDDVFactory;
  +import org.apache.xerces.impl.dv.InvalidDatatypeValueException;
   
   import org.apache.xerces.util.SymbolTable;
   import org.apache.xerces.util.XMLChar;
  @@ -123,7 +117,7 @@
    * @author Andy Clark, IBM
    * @author Jeffrey Rodriguez IBM
    *
  - * @version $Id: XMLDTDValidator.java,v 1.17 2002/01/29 20:44:02 neilg Exp $
  + * @version $Id: XMLDTDValidator.java,v 1.18 2002/02/15 16:00:29 sandygao Exp $
    */
   public class XMLDTDValidator
   implements XMLComponent, 
  @@ -214,6 +208,9 @@
   
       // updated during reset
       protected ValidationManager fValidationManager = null;
  +    
  +    // validation state
  +    protected ValidationState   fValidationState   = new ValidationState();
   
       // features
   
  @@ -232,9 +229,9 @@
        */
       protected boolean fDynamicValidation;
   
  -	/** warn on duplicate attribute definition, this feature works only when validation is true */
  -	protected boolean fWarnDuplicateAttdef;
  -	
  +        /** warn on duplicate attribute definition, this feature works only when validation is true */
  +        protected boolean fWarnDuplicateAttdef;
  +        
       // properties
   
       /** Symbol table. */
  @@ -247,7 +244,7 @@
       protected DTDGrammarBucket fGrammarBucket;
   
       /** Datatype validator factory. */
  -    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
  +    protected DTDDVFactory fDatatypeValidatorFactory;
   
       // handlers
   
  @@ -445,19 +442,19 @@
       // attribute validators
   
       /** Datatype validator: ID. */
  -    private IDDatatypeValidator fValID;
  +    private DatatypeValidator fValID;
   
       /** Datatype validator: IDREF. */
  -    private IDREFDatatypeValidator fValIDRef;
  +    private DatatypeValidator fValIDRef;
   
       /** Datatype validator: IDREFS. */
  -    private ListDatatypeValidator fValIDRefs;
  +    private DatatypeValidator fValIDRefs;
   
       /** Datatype validator: ENTITY. */
  -    private ENTITYDatatypeValidator fValENTITY;
  +    private DatatypeValidator fValENTITY;
   
       /** Datatype validator: ENTITIES. */
  -    private ListDatatypeValidator fValENTITIES;
  +    private DatatypeValidator fValENTITIES;
   
       /** Datatype validator: NMTOKEN. */
       private DatatypeValidator fValNMTOKEN;
  @@ -466,18 +463,7 @@
       private DatatypeValidator fValNMTOKENS;
   
       /** Datatype validator: NOTATION. */
  -    private NOTATIONDatatypeValidator fValNOTATION;
  -
  -    /**
  -     * This table has to be own by instance of XMLValidator and shared
  -     * among ID, IDREF and IDREFS. 
  -     * <p>
  -     * <strong>Note:</strong> Only ID has read/write access.
  -     * <p>
  -     * <strong>Note:</strong> Should revisit and replace with a ligther
  -     * structure.
  -     */
  -    private Hashtable fTableOfIDs; 
  +    private DatatypeValidator fValNOTATION;
   
       // to check for duplicate ID or ANNOTATION attribute declare in
       // ATTLIST, and misc VCs
  @@ -582,11 +568,13 @@
   
           fValidationManager= (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
           fValidationManager.reset();
  +        fValidationManager.addValidationState(fValidationState);
  +        fValidationState.resetIDTables();
           // 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);
           fGrammarBucket = new DTDGrammarBucket();
  -        fDatatypeValidatorFactory = (DatatypeValidatorFactory)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY);
  +        fDatatypeValidatorFactory = (DTDDVFactory)componentManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY);
   
           fElementDepth = -1;                      
           init();
  @@ -1389,24 +1377,24 @@
   
           if (fValidation) {
           
  -        	boolean	duplicateAttributeDef = false ;
  +                boolean	duplicateAttributeDef = false ;
                                           
  -        	//Get Grammar index to grammar array
  -        	int elementIndex       = fDTDGrammar.getElementDeclIndex( elementName, -1 );        	
  -        	if (fDTDGrammar.getAttributeDeclIndex(elementIndex, attributeName) != -1) {        
  -        		//more than one attribute definition is provided for the same attribute of a given element type.
  -        		duplicateAttributeDef = true ;
  -                		
  -        		//this feature works only when valiation is true.
  -        		if(fWarnDuplicateAttdef){
  -				fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  -							 "MSG_DUPLICATE_ATTRIBUTE_DEFINITION", 
  -							 new Object[]{ elementName, attributeName },
  -							 XMLErrorReporter.SEVERITY_WARNING );
  -			}        		
  -        	}
  +                //Get Grammar index to grammar array
  +                int elementIndex       = fDTDGrammar.getElementDeclIndex( elementName, -1 );        	
  +                if (fDTDGrammar.getAttributeDeclIndex(elementIndex, attributeName) != -1) {        
  +                        //more than one attribute definition is provided for the same attribute of a given element type.
  +                        duplicateAttributeDef = true ;
  +                                
  +                        //this feature works only when valiation is true.
  +                        if(fWarnDuplicateAttdef){
  +                                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                                         "MSG_DUPLICATE_ATTRIBUTE_DEFINITION", 
  +                                                         new Object[]{ elementName, attributeName },
  +                                                         XMLErrorReporter.SEVERITY_WARNING );
  +                        }
  +                }
  +                
                   
  -        	
               //
               // a) VC: One ID per Element Type, If duplicate ID attribute
               // b) VC: ID attribute Default. if there is a declareared attribute
  @@ -1427,25 +1415,25 @@
                       fTableOfIDAttributeNames.put(elementName, attributeName);
                   }
                   else {
  -                	//we should not report an error, when there is duplicate attribute definition for given element type
  -                	//according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given
  -                	//element type, the first declaration is binding and later declaration are *ignored*. So processor should 
  -                	//ignore the second declarations, however an application would be warned of the duplicate attribute defintion 
  -                	// if http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is set to true,
  -                	// one typical case where this could be a  problem, when any XML file  
  -                	// provide the ID type information through internal subset so that it is available to the parser which read 
  -                	//only internal subset. Now that attribute declaration(ID Type) can again be part of external parsed entity 
  -                	//referenced. At that time if parser doesn't make this distinction it will throw an error for VC One ID per 
  -                	//Element Type, which (second defintion) actually should be ignored. Application behavior may differ on the
  -                	//basis of error or warning thrown. - nb.
  -
  -                	if(!duplicateAttributeDef){
  -                    		String previousIDAttributeName = (String)fTableOfIDAttributeNames.get( elementName );//rule a)
  -                    		fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                        //we should not report an error, when there is duplicate attribute definition for given element type
  +                        //according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given
  +                        //element type, the first declaration is binding and later declaration are *ignored*. So processor should 
  +                        //ignore the second declarations, however an application would be warned of the duplicate attribute defintion 
  +                        // if http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is set to true,
  +                        // one typical case where this could be a  problem, when any XML file  
  +                        // provide the ID type information through internal subset so that it is available to the parser which read 
  +                        //only internal subset. Now that attribute declaration(ID Type) can again be part of external parsed entity 
  +                        //referenced. At that time if parser doesn't make this distinction it will throw an error for VC One ID per 
  +                        //Element Type, which (second defintion) actually should be ignored. Application behavior may differ on the
  +                        //basis of error or warning thrown. - nb.
  +
  +                        if(!duplicateAttributeDef){
  +                                String previousIDAttributeName = (String)fTableOfIDAttributeNames.get( elementName );//rule a)
  +                                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                                  "MSG_MORE_THAN_ONE_ID_ATTRIBUTE",
                                                  new Object[]{ elementName, previousIDAttributeName, attributeName},
                                                  XMLErrorReporter.SEVERITY_ERROR);
  -                	}
  +                        }
                   }
               }
   
  @@ -1464,17 +1452,17 @@
                       fTableOfNOTATIONAttributeNames.put( elementName, attributeName);
                   }
                   else {
  -                	//we should not report an error, when there is duplicate attribute definition for given element type
  -                	//according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given
  -                	//element type, the first declaration is binding and later declaration are *ignored*. So processor should 
  -                	//ignore the second declarations, however an application would be warned of the duplicate attribute defintion 
  -                	// if http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is set to true, Application behavior may differ on the basis of error or 
  -                	//warning thrown. - nb.
  +                        //we should not report an error, when there is duplicate attribute definition for given element type
  +                        //according to XML 1.0 spec, When more than one definition is provided for the same attribute of a given
  +                        //element type, the first declaration is binding and later declaration are *ignored*. So processor should 
  +                        //ignore the second declarations, however an application would be warned of the duplicate attribute defintion 
  +                        // if http://apache.org/xml/features/validation/warn-on-duplicate-attdef feature is set to true, Application behavior may differ on the basis of error or 
  +                        //warning thrown. - nb.
   
  -                	if(!duplicateAttributeDef){
  +                        if(!duplicateAttributeDef){
                   
  -                    		String previousNOTATIONAttributeName = (String) fTableOfNOTATIONAttributeNames.get( elementName );
  -                    		fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                String previousNOTATIONAttributeName = (String) fTableOfNOTATIONAttributeNames.get( elementName );
  +                                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                                  "MSG_MORE_THAN_ONE_NOTATION_ATTRIBUTE",
                                                  new Object[]{ elementName, previousNOTATIONAttributeName, attributeName},
                                                  XMLErrorReporter.SEVERITY_ERROR);
  @@ -1754,9 +1742,6 @@
           // check VC: Notation declared,  in the production of NDataDecl
           if (fValidation) {
   
  -            fValENTITY.initialize(fDTDGrammar);//Initialize ENTITY, ENTITIES validators 
  -            fValENTITIES.initialize(fDTDGrammar);
  -
               // VC : Notation Declared. for external entity declaration [Production 76].
               Enumeration entities = fNDataDeclNotations.keys();
               while (entities.hasMoreElements()) {
  @@ -2279,17 +2264,16 @@
   
                   try {
                       if (isAlistAttribute) {
  -                        fValENTITIES.validate(attValue, null);
  +                        fValENTITIES.validate(attValue, fValidationState);
                       }
                       else {
  -                        fValENTITY.validate(attValue, null);
  +                        fValENTITY.validate(attValue, fValidationState);
                       }
                   }
                   catch (InvalidDatatypeValueException ex) {
  -                    String  key = ex.getKeyIntoReporter();
                       fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  -                                               key,
  -                                               new Object[]{ ex.getMessage()},
  +                                               ex.getKey(),
  +                                               ex.getArgs(),
                                                  XMLErrorReporter.SEVERITY_ERROR );
   
                   }
  @@ -2327,13 +2311,12 @@
   
           case XMLSimpleType.TYPE_ID: {
                   try {
  -                    fValID.validate(attValue, null);
  +                    fValID.validate(attValue, fValidationState);
                   }
                   catch (InvalidDatatypeValueException ex) {
  -                    String  key = ex.getKeyIntoReporter();
                       fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  -                                               key,
  -                                               new Object[] { ex.getMessage()},
  +                                               ex.getKey(),
  +                                               ex.getArgs(),
                                                  XMLErrorReporter.SEVERITY_ERROR );
                   }
                   break;
  @@ -2344,21 +2327,20 @@
   
                   try {
                       if (isAlistAttribute) {
  -                        //System.out.println("values = >>" + value + "<<" );
  -                        fValIDRefs.validate(attValue, null);
  +                        fValIDRefs.validate(attValue, fValidationState);
                       }
                       else {
  -                        fValIDRef.validate(attValue, null);
  +                        fValIDRef.validate(attValue, fValidationState);
                       }
                   }
                   catch (InvalidDatatypeValueException ex) {
  -                    String key = ex.getKeyIntoReporter();
  -                    if (key == null) {
  +                    String key = ex.getKey();
  +                    if (isAlistAttribute) {
                           key = "IDREFSInvalid";
                       }
                       fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                                  key,
  -                                               new Object[]{ ex.getMessage()},
  +                                               ex.getArgs(),
                                                  XMLErrorReporter.SEVERITY_ERROR );
   
                   }
  @@ -2370,10 +2352,10 @@
                   //changes fTempAttDef
                   try {
                       if (isAlistAttribute) {
  -                        fValNMTOKENS.validate(attValue, null);
  +                        fValNMTOKENS.validate(attValue, fValidationState);
                       }
                       else {
  -                        fValNMTOKEN.validate(attValue, null);
  +                        fValNMTOKEN.validate(attValue, fValidationState);
                       }
                   }
                   catch (InvalidDatatypeValueException ex) {
  @@ -2775,15 +2757,14 @@
               try {
                   //REVISIT: datatypeRegistry + initialization of datatype 
                   //         why do we cast to ListDatatypeValidator?
  -                ((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).initializeDTDRegistry();
  -                fValID       = (IDDatatypeValidator)((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("ID" );
  -                fValIDRef    = (IDREFDatatypeValidator)((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("IDREF" );
  -                fValIDRefs   = (ListDatatypeValidator)((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("IDREFS" );
  -                fValENTITY   = (ENTITYDatatypeValidator)((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("ENTITY" );
  -                fValENTITIES = (ListDatatypeValidator)((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("ENTITIES" );
  -                fValNMTOKEN  = ((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("NMTOKEN");
  -                fValNMTOKENS = ((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("NMTOKENS");
  -                fValNOTATION = (NOTATIONDatatypeValidator)((DatatypeValidatorFactoryImpl)fDatatypeValidatorFactory).getDatatypeValidator("NOTATION" );
  +                fValID       = fDatatypeValidatorFactory.getBuiltInDV("ID" );
  +                fValIDRef    = fDatatypeValidatorFactory.getBuiltInDV("IDREF" );
  +                fValIDRefs   = fDatatypeValidatorFactory.getBuiltInDV("IDREFS" );
  +                fValENTITY   = fDatatypeValidatorFactory.getBuiltInDV("ENTITY" );
  +                fValENTITIES = fDatatypeValidatorFactory.getBuiltInDV("ENTITIES" );
  +                fValNMTOKEN  = fDatatypeValidatorFactory.getBuiltInDV("NMTOKEN");
  +                fValNMTOKENS = fDatatypeValidatorFactory.getBuiltInDV("NMTOKENS");
  +                fValNOTATION = fDatatypeValidatorFactory.getBuiltInDV("NOTATION" );
   
               }
               catch (Exception e) {
  @@ -2791,15 +2772,6 @@
                   e.printStackTrace(System.err);
               }
   
  -            //Initialize ID, IDREF, IDREFS validators
  -            if (fTableOfIDs == null) {
  -                fTableOfIDs = new Hashtable();//Initialize table of IDs
  -            }
  -
  -            fTableOfIDs.clear();
  -            fValID.initialize(fTableOfIDs);
  -            fValIDRef.initialize(fTableOfIDs);
  -            fValIDRefs.initialize(fTableOfIDs);
               if (fNotationEnumVals == null) {
                   fNotationEnumVals = new Hashtable(); 
               }
  @@ -2873,7 +2845,7 @@
           // see if the root element's name matches the one in DoctypeDecl 
           if (!fSeenRootElement) {
               fSeenRootElement = true;
  -            fValidationManager.getValidationState().setEntityState(fDTDGrammar);
  +            fValidationManager.setEntityState(fDTDGrammar);
               fValidationManager.setGrammarFound(fSeenDoctypeDecl);
               rootElementSpecified(element);
           }
  @@ -3023,19 +2995,13 @@
               //   IDREF and IDREFS attr (V_IDREF0)
               //
               if (fPerformValidation) {
  -                try {
  -                    fValIDRef.validate();//Do final validation of IDREFS against IDs
  -                    fValIDRefs.validate();
  -                }
  -                catch (InvalidDatatypeValueException ex) {
  -                    String  key = ex.getKeyIntoReporter();
  -
  +                String value = fValidationState.checkIDRefID();
  +                if (value != null) {
                       fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,
  -                                                key,
  -                                                new Object[]{ ex.getMessage()},
  +                                                "MSG_ELEMENT_WITH_ID_REQUIRED",
  +                                                new Object[]{value},
                                                   XMLErrorReporter.SEVERITY_ERROR );
                   }
  -                fTableOfIDs.clear();//Clear table of IDs
               }
               return;
           }
  
  
  
  1.5       +2 -2      xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLSimpleType.java
  
  Index: XMLSimpleType.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLSimpleType.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLSimpleType.java	29 Jan 2002 01:15:10 -0000	1.4
  +++ XMLSimpleType.java	15 Feb 2002 16:00:29 -0000	1.5
  @@ -56,9 +56,9 @@
    */
   
   package org.apache.xerces.impl.dtd;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidator;
  +import org.apache.xerces.impl.dv.DatatypeValidator;
   /**
  - * @version $Id: XMLSimpleType.java,v 1.4 2002/01/29 01:15:10 lehors Exp $
  + * @version $Id: XMLSimpleType.java,v 1.5 2002/02/15 16:00:29 sandygao Exp $
    */
   public class XMLSimpleType {
   
  
  
  
  1.3       +83 -4     xml-xerces/java/src/org/apache/xerces/impl/dv/DTDDVFactory.java
  
  Index: DTDDVFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/DTDDVFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DTDDVFactory.java	29 Jan 2002 01:15:11 -0000	1.2
  +++ DTDDVFactory.java	15 Feb 2002 16:00:29 -0000	1.3
  @@ -66,9 +66,88 @@
    *
    * @author Sandy Gao, IBM
    *
  - * @version $Id: DTDDVFactory.java,v 1.2 2002/01/29 01:15:11 lehors Exp $
  + * @version $Id: DTDDVFactory.java,v 1.3 2002/02/15 16:00:29 sandygao Exp $
    */
  -interface DTDDVFactory {
  +public abstract class DTDDVFactory {
  +
  +    private static final String DEFAULT_FACTORY_CLASS = "org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl";
  +
  +    private static String       fFactoryClass    = null;
  +    private static DTDDVFactory fFactoryInstance = null;
  +
  +    /**
  +     * Set the class name of the dtd factory implementation. This method
  +     * can only be called before the first time the method <code>getInstance</code>
  +     * successfully returns, otherwise a DVFactoryException will be thrown.
  +     *
  +     * @param className  the class name of the DTDDVFactory implementation
  +     * @exception DVFactoryException  the method cannot be called at this time
  +     */
  +    public static final void setFactoryClass(String factoryClass) throws DVFactoryException {
  +        // if the factory instance has been created, it's an error.
  +        if (fFactoryInstance != null)
  +            throw new DVFactoryException("Cannot set the class name now. The class name '"+fFactoryClass+"' is already used.");
  +
  +        // synchronize on the string value
  +        synchronized (DEFAULT_FACTORY_CLASS) {
  +            // in case this thread was waiting for another thread
  +            if (fFactoryInstance != null)
  +                throw new DVFactoryException("Cannot set the class name now. The class name '"+fFactoryClass+"' is already used.");
  +
  +            fFactoryClass = factoryClass;
  +        }
  +    }
  +
  +    /**
  +     * Get an instance of DTDDVFactory implementation.
  +     *
  +     * If <code>setFactoryClass</code> is called before this method,
  +     * the passed-in class name will be used to create the factory instance.
  +     * Otherwise, a default implementation is used.
  +     *
  +     * After the first time this method successfully returns, any subsequent
  +     * invocation to this method returns the same instance.
  +     *
  +     * @return  an instance of DTDDVFactory implementation
  +     * @exception DVFactoryException  cannot create an instance of the specified
  +     *                                class name or the default class name
  +     */
  +    public static final DTDDVFactory getInstance() throws DVFactoryException {
  +        // if the factory instance has been created, just return it.
  +        if (fFactoryInstance != null)
  +            return fFactoryInstance;
  +
  +        // synchronize on the string value, to make sure that we don't create
  +        // two instance of the dv factory class
  +        synchronized (DEFAULT_FACTORY_CLASS) {
  +            // in case this thread was waiting for another thread to create
  +            // the factory instance, just return the instance created by the
  +            // other thread.
  +            if (fFactoryInstance != null)
  +                return fFactoryInstance;
  +
  +            try {
  +                // if the class name is not specified, use the default one
  +                if (fFactoryClass == null)
  +                    fFactoryClass = DEFAULT_FACTORY_CLASS;
  +                fFactoryInstance = (DTDDVFactory)(Class.forName(fFactoryClass).newInstance());
  +            } catch (ClassNotFoundException e1) {
  +                throw new DVFactoryException("DTD factory class " + fFactoryClass + " not found.");
  +            } catch (IllegalAccessException e2) {
  +                throw new DVFactoryException("DTD factory class " + fFactoryClass + " found but cannot be loaded.");
  +            } catch (InstantiationException e3) {
  +                throw new DVFactoryException("DTD factory class " + fFactoryClass + " loaded but cannot be instantiated (no empty public constructor?).");
  +            } catch (ClassCastException e4) {
  +                throw new DVFactoryException("DTD factory class " + fFactoryClass + " does not extend from DTDDVFactory.");
  +            }
  +        }
  +
  +        // return the newly created dv factory instance
  +        return fFactoryInstance;
  +    }
  +
  +    // can't create a new object of this class
  +    protected DTDDVFactory(){}
   
       /**
        * return a dtd type of the given name
  @@ -76,13 +155,13 @@
        * @param name  the name of the datatype
        * @return      the datatype validator of the given name
        */
  -    public DatatypeValidator getBuiltInDV(String name);
  +    public abstract DatatypeValidator getBuiltInDV(String name);
   
       /**
        * get all built-in DVs, which are stored in a hashtable keyed by the name
        *
        * @return      a hashtable which contains all datatypes
        */
  -    public Hashtable getBuiltInTypes();
  +    public abstract Hashtable getBuiltInTypes();
   
   }
  
  
  
  1.4       +2 -6      xml-xerces/java/src/org/apache/xerces/impl/dv/DatatypeValidator.java
  
  Index: DatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/DatatypeValidator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.3
  +++ DatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.4
  @@ -65,7 +65,7 @@
    *
    * @author Sandy Gao, IBM
    *
  - * @version $Id: DatatypeValidator.java,v 1.3 2002/01/29 01:15:11 lehors Exp $
  + * @version $Id: DatatypeValidator.java,v 1.4 2002/02/15 16:00:29 sandygao Exp $
    */
   public interface DatatypeValidator {
   
  @@ -74,12 +74,8 @@
        *
        * @param content       the string value that needs to be validated
        * @param context       the validation context
  -     *
  -     * @return              the actual value of the string value
  -     *                      (most likely a normalized string, since all types
  -     *                       in DTD are string types.)
        */
  -    public Object validate(String content, ValidationContext context)
  +    public void validate(String content, ValidationContext context)
           throws InvalidDatatypeValueException;
   
   }
  
  
  
  1.6       +20 -131   xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/ENTITYDatatypeValidator.java
  
  Index: ENTITYDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/ENTITYDatatypeValidator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ENTITYDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.5
  +++ ENTITYDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.6
  @@ -57,15 +57,8 @@
   
   package org.apache.xerces.impl.dv.dtd;
   
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Locale;
  -import java.util.StringTokenizer;
  -
  -
  -import org.apache.xerces.impl.dtd.XMLEntityDecl;
  -import org.apache.xerces.impl.dtd.DTDGrammar;
  -
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   
   /**
    * <P>ENTITYDatatypeValidator implements the
  @@ -80,137 +73,33 @@
    * strings that match the NCName production.
    * The value space of ENTITY is scoped to a specific
    * instance document.</P>
  - * <P>This is a statefull datatype validator and it
  - * needs access to a valid Grammar structure to being 
  - * able to validate entities.</P>
    * 
  - * @author Jeffrey Rodriguez-
  - * @version $Id: ENTITYDatatypeValidator.java,v 1.5 2002/01/29 01:15:11 lehors Exp $
  - * @see org.apache.xerces.impl.dtd.AbstractDTDGrammar
  - * @see org.apache.xerces.impl.dtd.DTDGrammar
  - * @see org.apache.xerces.impl.xs.SchemaGrammar
  + * @author Jeffrey Rodriguez, IBM
  + * @author Sandy Gao, IBM
  + * 
  + * @version $Id: ENTITYDatatypeValidator.java,v 1.6 2002/02/15 16:00:29 sandygao Exp $
    */
  -public class ENTITYDatatypeValidator extends AbstractDatatypeValidator 
  -implements StatefullDatatypeValidator {
  -    private DatatypeValidator        fBaseValidator    = null;
  -    private DTDGrammar                  fGrammar          = null;
  -    private XMLEntityDecl            fEntityDecl       = new XMLEntityDecl();
  -
  -    public ENTITYDatatypeValidator () throws InvalidDatatypeFacetException {
  -        this( null, null, false ); // Native, No Facets defined, Restriction
  -    }
  +public class ENTITYDatatypeValidator implements DatatypeValidator {
   
  -    public ENTITYDatatypeValidator ( DatatypeValidator base, Hashtable facets,
  -                                     boolean derivedByList  ) throws InvalidDatatypeFacetException {
  -        setBasetype( base ); // Set base type
  +    // construct an ENTITY datatype validator
  +    public ENTITYDatatypeValidator() {
       }
   
  -
       /**
  -     * <P>Checks that "content" string is valid
  -     * datatype.
  -     * If invalid a Datatype validation exception is thrown.</P>
  -     * <P>The following constrain is checked:
  -     * ENTITY values must match an unparsed entity 
  -     * name that is declared in the schema.</P> 
  +     * Checks that "content" string is valid ID value.
  +     * If invalid a Datatype validation exception is thrown.
        * 
  -     * @param content A string containing the content to be validated
  -     * @param state
  -     * @exception throws InvalidDatatypeException if the content is
  -     *                   invalid according to the rules for the validators
  -     * @exception InvalidDatatypeValueException
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
        * @see InvalidDatatypeValueException
        */
  -    public void validate(String content, Object state ) throws InvalidDatatypeValueException{
  -        int entityDeclIndex = -1;
  -        if (fGrammar == null) {
  -            InvalidDatatypeValueException error = 
  -            new InvalidDatatypeValueException();//Need Message
  -            error.setKeyIntoReporter( "ENTITYFailedInitializeGrammar");
  -            throw error;
  -        }
  -
  -        fEntityDecl.clear();//Reset Entity Decl struct
  -
  -        entityDeclIndex = fGrammar.getEntityDeclIndex( content );
  -
  -        if (entityDeclIndex > -1) {
  -            fGrammar.getEntityDecl( entityDeclIndex, fEntityDecl );
  -            if (fEntityDecl.notation == null) {// not unparsed entity
  -                InvalidDatatypeValueException error = 
  -                new InvalidDatatypeValueException( content );
  -                error.setKeyIntoReporter( "ENTITYNotUnparsed" );
  -                throw error;
  -            }
  -        } else {
  -            InvalidDatatypeValueException error = 
  -            new InvalidDatatypeValueException( content );
  -            error.setKeyIntoReporter( "ENTITYNotValid" );
  -            throw error;
  -        }
  -    }
  -
  -    /**
  -     * A no-op method in this Datatype
  -     */
  -    public void validate(){
  -    }
  -
  -
  -
  -    /**
  -     * <P>Initializes internal Grammar reference
  -     * This method is unique to ENTITYDatatypeValidator.</P>
  -     * <P>This method should  be called before calling the
  -     * validate method</P>
  -     * 
  -     * @param grammar
  -     */
  -    public void initialize( Object grammar ) {
  -        //System.out.println("ENTITYDatatypeValidator initialized" );
  -        fGrammar = (DTDGrammar) grammar;
  -        //System.out.println("grammar = " + fGrammar );
  -    }
  -
  -    /**
  -     * REVISIT
  -     * Compares two Datatype for order
  -     * 
  -     * @return  0 if value1 and value2 are equal, a value less than 0 if value1 is less than value2, a value greater than 0 if value1 is greater than value2
  -     */
  -    public int compare( String  content1, String content2) {
  -        return -1;
  -    }
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
   
  -    public Hashtable getFacets() {
  -        return null;
  +        if (!context.isEntityUnparsed(content))
  +            throw new InvalidDatatypeValueException("ENTITYNotUnparsed", new Object[]{content});
  +            
       }
  -
  -    // Private methods start here
  -
  -    /**
  -       * Returns a copy of this object.
  -       */
  -    public Object clone() throws CloneNotSupportedException {
  -        throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
  -    }
  -
  -
  -   /**
  -    * A no-op method in this validator
  -    */
  -    public Object getInternalStateInformation() {
  -    return null;
  -    }
  -
  -    /**
  -     * 
  -     * @param base   the validator for this type's base type
  -     */
  -    private void setBasetype(DatatypeValidator base) {
  -        fBaseValidator = base;
  -    }
  -
  -
  -
  +    
   }
  
  
  
  1.5       +23 -193   xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/IDDatatypeValidator.java
  
  Index: IDDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/IDDatatypeValidator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IDDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.4
  +++ IDDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.5
  @@ -54,16 +54,12 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  +
   package org.apache.xerces.impl.dv.dtd;
   
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Locale;
  -import java.util.Vector;
  -import java.util.StringTokenizer;
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   import org.apache.xerces.util.XMLChar;
  -import java.util.NoSuchElementException;
  -
   
   /**
    * <P>IDDatatypeValidator - ID represents the ID attribute
  @@ -79,206 +75,40 @@
    * document as a value of this type; i.e., ID values
    * must uniquely identify the elements which bear
    * them.</P>
  - * <P>An ID validator is a statefull validator, it needs
  - * read/write access to the associated instant document
  - * table of IDs.</P>
  - * <P>
  - * The following snippet shows typical use of the
  - * the IDDatatype:</P>
  - * <CODE>
  - * <PRE>
  - *  DatatypeValidator  idData = tstRegistry.getDatatypeValidator( "ID" );
  - * 
  - *       if (  idData != null ) {
  - *          ((IDDatatypeValidator) idData).initialize();
  - *          try {
  - *             idData.validate( "a1", null );
  - *             idData.validate( "a2", null );
  - *          } catch ( Exception ex ) {
  - *             ex.printStackTrace();
  - *          }
  - *          Hashtable tst = (Hashtable)((IDDatatypeValidator) idData).getTableIds();
  - *          if (tst != null) {
  - *             System.out.println("Table of ID = " + tst.toString());
  - *          }
  - * 
  - *       }
    * 
  - *       DatatypeValidator idRefData = tstRegistry.getDatatypeValidator("IDREF" );
  - *       if( idRefData != null ){
  - *          IDREFDatatypeValidator refData = (IDREFDatatypeValidator) idRefData;
  - *          refData.initialize( ((IDDatatypeValidator) idData).getTableIds());
  - *          try {
  - *             refData.validate( "a1", null );
  - *             refData.validate( "a2", null );
  - *             //refData.validate( "a3", null );//Should throw exception at validate()
  - *             refData.validate();
  - *          } catch( Exception ex ){
  - *             ex.printStackTrace();
  - *          }
  - *       }
  - *       </PRE>
  - * </CODE>
  + * @author Jeffrey Rodriguez, IBM
  + * @author Sandy Gao, IBM
    * 
  - * @author Jeffrey Rodriguez
  - * @version $Id: IDDatatypeValidator.java,v 1.4 2002/01/29 01:15:11 lehors Exp $
  - * @see AbstractDatatypeValidator
  - * @see DatatypeValidator
  - * @see IDREFDatatypeValidator
  + * @version $Id: IDDatatypeValidator.java,v 1.5 2002/02/15 16:00:29 sandygao Exp $
    */
  -public class IDDatatypeValidator extends AbstractDatatypeValidator 
  -implements StatefullDatatypeValidator {
  -    private DatatypeValidator       fBaseValidator;
  -    private Object                  fNullValue;
  -    private DatatypeMessageProvider fMessageProvider = new DatatypeMessageProvider();
  -    private Hashtable               fTableOfId;
  -    private Locale                  fLocale;
  -
  -
  -
  -    public IDDatatypeValidator () throws InvalidDatatypeFacetException {
  -        this( null, null, false ); // Native, No Facets defined, Restriction
  -    }
  +public class IDDatatypeValidator implements DatatypeValidator {
   
  -    public IDDatatypeValidator ( DatatypeValidator base, Hashtable facets, 
  -                                 boolean derivedByList ) throws InvalidDatatypeFacetException  {
  +    // construct an ID datatype validator
  +    public IDDatatypeValidator() {
       }
   
  -
  -
       /**
  -     * Checks that "content" string is valid
  -     * datatype.
  +     * Checks that "content" string is valid ID value.
        * If invalid a Datatype validation exception is thrown.
        * 
  -     * @param content A string containing the content to be validated
  -     * @param state  Generic Object state that can be use to pass
  -     *               Structures
  -     * @exception throws InvalidDatatypeException if the content is
  -     *                   invalid according to the rules for the validators
  -     * @exception InvalidDatatypeValueException
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
        * @see InvalidDatatypeValueException
        */
  -    public void validate(String content, Object state ) throws InvalidDatatypeValueException{
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
   
  -        boolean status;
  -        if ((status = XMLChar.isValidName(content) ) == false) {//Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
  -            InvalidDatatypeValueException error =  new
  -                                                   InvalidDatatypeValueException( content );
  -            error.setKeyIntoReporter( "IDInvalid" );
  -            throw error;
  +        //Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
  +        if (!XMLChar.isValidName(content)) {
  +            throw new InvalidDatatypeValueException("IDInvalid", new Object[]{content});
           }
  -        if (!addId( content)) { //It is OK to pass a null here
  -            InvalidDatatypeValueException error = 
  -            new InvalidDatatypeValueException( content );
  -            error.setKeyIntoReporter( "IDNotUnique" );
  -            throw error;
  -        }
  -    }
  -
  -    /**
  -     * A no-op method in this Datatype
  -     */
  -    public void validate() throws InvalidDatatypeValueException{
  -    }
  -
  -
  -    /**
  -     * Initializes internal table of IDs used
  -     * by ID datatype validator to keep track
  -     * of ID's.
  -     * This method is unique to IDDatatypeValidator.
  -     * 
  -     * @param state  This is a dummy parameter.
  -     */
  -    public void initialize( Object tableOfIDs) {
  -        fTableOfId = (Hashtable) tableOfIDs;
  -    }
  -
  -    /**
  -     * REVISIT
  -     * Compares two Datatype for order
  -     * 
  -     * @param o1
  -     * @param o2
  -     * @return 0 if value1 and value2 are equal, a value less than 0 if value1 is less than value2, a value greater than 0 if value1 is greater than value2
  -     */
  -    public int compare( String content1, String content2) {
  -        return -1;
  -    }
  -
  -    public Hashtable getFacets() {
  -        return null;
  -    }
   
  -    /**
  -       * Return a copy of this object.
  -       */
  -    public Object clone() throws CloneNotSupportedException {
  -        throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
  -    }
  -
  -    /**
  -     * This method is unique to IDDatatypeValidator.
  -     * It returns a reference to the internal ID table.
  -     * This method should be used by the IDREF datatype
  -     * validator which needs read access to ID table.
  -     * 
  -     * @return internal state of the validator (in this case the ID table)
  -     */
  -    public Object getInternalStateInformation() {
  -        return fTableOfId;
  -    }
  -
  -
  -    /**
  -     * Name of base type as a string.
  -     * A Native datatype has the string "native"  as its
  -     * base type.
  -     * 
  -     * @param base   the validator for this type's base type
  -     */
  -    private void setBasetype(DatatypeValidator base) {
  -        fBaseValidator = base;
  -    }
  -
  -    /**
  -     * Adds validated ID to internal table of ID's.
  -     * We check ID uniqueness constraint.
  -     * 
  -     * @param content
  -     * @return    If ID validated is not unique we return a false and
  -     *         then validate method throws a validation exception.
  -     */
  -    private boolean addId(String content) {
  -        if (fTableOfId.containsKey( content ) == true ) {
  -            return false;
  -        }
  -        if (this.fNullValue == null) {
  -            fNullValue = new Object();
  -        }
  -        try {
  -            fTableOfId.put( content, fNullValue ); 
  -        } catch (Exception ex) {
  -            ex.printStackTrace();
  +        if (context.isIdDeclared(content)) {
  +            throw new InvalidDatatypeValueException("IDNotUnique", new Object[]{content});
           }
  -        return true;
  -    } // addId(int):boolean
  -
  -
  -
  -    /**
  -     * set the locate to be used for error messages
  -     */
  -    public void setLocale(Locale locale) {
  -        fLocale = locale;
  +        
  +        context.addId(content);
       }
  -
  -
  -    private String getErrorString(int major, int minor, Object args[]) {
  -        //return fMessageProvider.createMessage(fLocale, major, minor, args);
  -        return fMessageProvider.formatMessage(fLocale, null, null );
  -    }
  -
  -
  +    
   }
  
  
  
  1.5       +30 -230   xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/IDREFDatatypeValidator.java
  
  Index: IDREFDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/IDREFDatatypeValidator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IDREFDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.4
  +++ IDREFDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.5
  @@ -57,12 +57,10 @@
   
   package org.apache.xerces.impl.dv.dtd;
   
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Locale;
  -import java.util.StringTokenizer;
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   import org.apache.xerces.util.XMLChar;
  -import java.util.NoSuchElementException;
  +
   /**
    * <P>IDREFDatatypeValidator - represents the IDREFS
    * attribute type from XML 1.0 recommendation. The
  @@ -74,235 +72,37 @@
    * production.</P>
    * <P>The Value space of IDREF is scoped to a specific
    * instance document</P>
  - * <P>This datatatype checks the following constraint:
  - * An IDREF must match the value of an ID in the XML
  - * document in which it occurs.
  - * </P>
  - * The following snippet shows typical use of the
  - * the IDDatatype:</P>
  - * <CODE>
  - * <PRE>
  - *       DatatypeValidator idRefData = tstRegistry.getDatatypeValidator("IDREF" );
  - *       if( idRefData != null ){
  - *          IDREFDatatypeValidator refData = (IDREFDatatypeValidator) idRefData;
  - *          refData.initialize( ((IDDatatypeValidator) idData).getTableIds());
  - *          try {
  - *             refData.validate( "a1", null );
  - *             refData.validate( "a2", null );
  - *             //refData.validate( "a3", null );//Should throw exception at validate()
  - *             refData.validate();
  - *          } catch( Exception ex ){
  - *             ex.printStackTrace();
  - *          }
  - *       }
  - *       </PRE>
  - * </CODE>
    * 
  - * @author Jeffrey Rodriguez-
  - * @version $Id: IDREFDatatypeValidator.java,v 1.4 2002/01/29 01:15:11 lehors Exp $
  - * @see IDDatatypeValidator
  - * @see DatatypeValidator
  - * @see DatatypeValidator
  + * @author Jeffrey Rodriguez, IBM
  + * @author Sandy Gao, IBM
  + * 
  + * @version $Id: IDREFDatatypeValidator.java,v 1.5 2002/02/15 16:00:29 sandygao Exp $
    */
  -public class IDREFDatatypeValidator extends AbstractDatatypeValidator
  -implements StatefullDatatypeValidator{
  -   private DatatypeValidator fBaseValidator    = null;
  -   private Hashtable              fTableOfId   = null; //This is pass to us through the state object
  -   private Hashtable              fTableIDRefs = null;
  -   private Object                   fNullValue = null;
  -   private Locale            fLocale           = null;
  -   private DatatypeMessageProvider fMessageProvider = new DatatypeMessageProvider();
  -
  -
  -   public IDREFDatatypeValidator () throws InvalidDatatypeFacetException {
  -      this( null, null, false ); // Native, No Facets defined, Restriction
  -   }
  -
  -   public IDREFDatatypeValidator ( DatatypeValidator base, Hashtable facets, 
  -                                   boolean derivedByList ) throws InvalidDatatypeFacetException { 
  -
  -      setBasetype( base ); // Set base type 
  -
  -   }
  -
  -
  -   /**
  -    * Checks that "content" string is valid 
  -    * datatype.
  -    * If invalid a Datatype validation exception is thrown.
  -    * 
  -    * @param content A string containing the content to be validated
  -    * @param derivedBylist
  -    *                Flag which is true when type
  -    *                is derived by list otherwise it
  -    *                it is derived by extension.
  -    *                
  -    * @exception throws InvalidDatatypeException if the content is
  -    *                   invalid according to the rules for the validators
  -    * @exception InvalidDatatypeValueException
  -    * @see         InvalidDatatypeValueException
  -    */
  -   public void validate(String content, Object state ) throws InvalidDatatypeValueException{
  -      //Pass content as a String
  -      if (!XMLChar.isValidName(content)) {//Check if is valid key
  -         InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );//Need Message
  -         error.setKeyIntoReporter( "IDREFInvalid" );
  -         throw error;//Need Message
  -      }
  -      addIdRef( content, state);// We are storing IDs 
  -   }
  -
  -   /**
  -    * <P>This method is unique to IDREFDatatypeValidator</P>
  -    * <P>Validator should call this method at the EndDocument
  -    * call to start IDREF constraint validation. This validation
  -    * rule checks IDREF values accumulated in internal
  -    * table against read table passed to IDREF validator
  -    * at instantiation time.</P>
  -    * <P>Caveats -
  -    * <LI>
  -    * Do not call this validator method until
  -    * you are sure that all ID values have been found since
  -    * this method contains a live reference to an internal
  -    * ID table which the ID validator could still be
  -    * updating.</LI>
  -    * <LI>Do not call this method before the initialize method
  -    * since the initialize method will set the reference
  -    * to ID table used by this method to validate the
  -    * IDREFs.</LI></P>
  -    * 
  -    * @exception InvalidDatatypeValueException
  -    */
  -   public void validate() throws InvalidDatatypeValueException{
  -      checkIdRefs();
  -   }
  -
  -
  -   /**
  -    * <P>This method is unique to IDREFDatatypeValidator</P>
  -    * <P>This method initializes the internal reference
  -    * to the ID table of ID's and IDREF internal table
  -    * of IDREFs.</P>
  -    * <P>This method should be called before the valid()
  -    * method</P>
  -    * 
  -    * @param tableOfIDs
  -    */
  -   public void initialize( Object tableOfIDs ){
  -      //System.out.println("IDREF datatype initialized" );
  -         
  -      if ( this.fTableIDRefs != null) {
  -         this.fTableIDRefs.clear();
  -      } else {
  -        this.fTableIDRefs = new Hashtable();
  -      }
  -      fTableOfId = (Hashtable) tableOfIDs; //set reference to table of Ids.
  -   }
  -
  -
  -
  -   /**
  -    * REVISIT
  -    * Compares two Datatype for order
  -    * 
  -    * @param o1
  -    * @param o2
  -    * @return 0 if value1 and value2 are equal, a value less than 0 if value1 is less than value2, a value greater than 0 if value1 is greater than value2
  -    */
  -   public int compare( String content1, String content2){
  -      return -1;
  -   }
  -
  -
  -   public Hashtable getFacets(){
  -      return null;
  -   }
  -   /**
  -      * Returns a copy of this object.
  -      */
  -   public Object clone() throws CloneNotSupportedException {
  -      throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
  -   }
  -
  -   /**
  -     * Name of base type as a string.
  -     * A Native datatype has the string "native"  as its
  -     * base type.
  +public class IDREFDatatypeValidator implements DatatypeValidator {
  +
  +    // construct an IDREF datatype validator
  +    public IDREFDatatypeValidator() {
  +    }
  +
  +    /**
  +     * Checks that "content" string is valid IDREF value.
  +     * If invalid a Datatype validation exception is thrown.
        * 
  -     * @param base   the validator for this type's base type
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
  +     * @see InvalidDatatypeValueException
        */
  -   private void setBasetype(DatatypeValidator base){
  -      fBaseValidator = base;
  -   }
  -
  -   /** addId. */
  -   private void addIdRef(String content, Object state) {
  -      if ( fTableOfId != null &&  fTableOfId.containsKey( content ) ) {
  -         return;
  -      }
  -      if ( fTableIDRefs == null ) {
  -         fTableIDRefs = new Hashtable();
  -      } else if ( fTableIDRefs.containsKey( content ) ) {
  -         return;
  -      }
  -      if ( this.fNullValue == null ) {
  -         fNullValue = new Object();
  -      }
  -      try {
  -         this.fTableIDRefs.put( content, fNullValue ); 
  -      } catch ( OutOfMemoryError ex ) {
  -         System.out.println( "Out of Memory: Hashtable of ID's has " + this.fTableIDRefs.size() + " Elements" );
  -         ex.printStackTrace();
  -      }
  -   } // addId(int):boolean
  -
  -
  -   /**
  -    * <P>Private method used to check the IDREF valid
  -    * ID constraint</P>
  -    * 
  -    * @exception InvalidDatatypeValueException
  -    */
  -   private void checkIdRefs() throws InvalidDatatypeValueException {
  -
  -      if ( fTableIDRefs == null)
  -         return;
  -
  -      Enumeration en = this.fTableIDRefs.keys();
  -
  -      while (en.hasMoreElements()) {
  -         String key = (String)en.nextElement();
  -         if ( this.fTableOfId == null || ! this.fTableOfId.containsKey(key)) {
  -
  -            InvalidDatatypeValueException error =  new
  -                                                   InvalidDatatypeValueException( key );
  -            error.setKeyIntoReporter("MSG_ELEMENT_WITH_ID_REQUIRED" );
  -            throw error;
  -         }
  -      }
  -
  -   } // checkIdRefs()
  -
  -
  -   /**
  -   * set the locate to be used for error messages
  -   */
  -   public void setLocale(Locale locale) {
  -      fLocale = locale;
  -   }
  -
  -   /**
  -    * A no-op method in this validator
  -    */
  -   public Object getInternalStateInformation(){
  -       return null;
  -   }
  -
  -   private String getErrorString(int major, int minor, Object args[]) {
  -      //return fMessageProvider.createMessage(fLocale, major, minor, args);
  -      return fMessageProvider.formatMessage( fLocale, null, null);
  -   }
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
   
  +        //Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
  +        if (!XMLChar.isValidName(content)) {
  +            throw new InvalidDatatypeValueException("IDREFInvalid", new Object[]{content});
  +        }
  +
  +        context.addIdRef(content);
  +        
  +    }
   
   }
  -
  
  
  
  1.3       +31 -263   xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/ListDatatypeValidator.java
  
  Index: ListDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/ListDatatypeValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.2
  +++ ListDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.3
  @@ -57,282 +57,50 @@
   
   package org.apache.xerces.impl.dv.dtd;
   
  -import java.util.Hashtable;
  -import java.util.Vector;
  -import java.util.Enumeration;
  -import java.util.Locale;
  -import java.text.Collator;
  -import java.util.Enumeration;
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   import java.util.StringTokenizer;
  -import java.util.NoSuchElementException;
  -
  -
   
   /**
  - * StringValidator validates that XML content is a W3C string type.
  + * For list types: ENTITIES, IDREFS, NMTOKENS.
  + * 
  + * @author Jeffrey Rodriguez, IBM
  + * @author Sandy Gao, IBM
  + * 
  + * @version $Id: ListDatatypeValidator.java,v 1.3 2002/02/15 16:00:29 sandygao Exp $
    */
  -public class ListDatatypeValidator extends AbstractDatatypeValidator
  -implements  StatefullDatatypeValidator {
  -    private Locale     fLocale          = null;
  -    DatatypeValidator  fBaseValidator   = null; // Native datatypes have null
  -
  -    private int        fLength           = 0;
  -    private int        fMaxLength        = Integer.MAX_VALUE;
  -    private int        fMinLength        = 0;
  -    private String     fPattern          = null;
  -    private Vector     fEnumeration      = null;
  -    private int        fFacetsDefined    = 0;
  -    private boolean    fDerivedByList    = false;//default
  -
  -    //private RegularExpression fRegex         = null;
  -
  -
  -
  -
  -    public  ListDatatypeValidator () throws InvalidDatatypeFacetException{
  -        this( null, null, false ); // Native, No Facets defined, Restriction
  +public class ListDatatypeValidator implements DatatypeValidator {
   
  -    }
  -
  -    public ListDatatypeValidator ( DatatypeValidator base, Hashtable facets, 
  -                                   boolean derivedByList ) throws InvalidDatatypeFacetException {
  -
  -        setBasetype( base ); // Set base type 
  -
  -        fDerivedByList = derivedByList;
  +    // the type of items in the list
  +    DatatypeValidator fItemValidator;
   
  -        if (facets != null) {
  -            for (Enumeration e = facets.keys(); e.hasMoreElements();) {
  -                String key = (String) e.nextElement();
  -                if (key.equals("length")) {
  -                    fFacetsDefined += DatatypeValidator.FACET_LENGTH;
  -                    String lengthValue = (String)facets.get(key);
  -                    try {
  -                        fLength     = Integer.parseInt( lengthValue );
  -                    } catch (NumberFormatException nfe) {
  -                        throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
  -                    }
  -                    if (fLength < 0)
  -                        throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"'  must be a nonNegativeInteger.");
  -
  -                } else if (key.equals("minlength")) {
  -                    fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
  -                    String minLengthValue = (String)facets.get(key);
  -                    try {
  -                        fMinLength     = Integer.parseInt( minLengthValue );
  -                    } catch (NumberFormatException nfe) {
  -                        throw new InvalidDatatypeFacetException("maxLength value '"+minLengthValue+"' is invalid.");
  -                    }
  -                } else if (key.equals("maxlength")) {
  -                    fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
  -                    String maxLengthValue = (String)facets.get(key);
  -                    try {
  -                        fMaxLength     = Integer.parseInt( maxLengthValue );
  -                    } catch (NumberFormatException nfe) {
  -                        throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
  -                    }
  -                } else if (key.equals("enumeration")) {
  -                    fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
  -                    fEnumeration    = (Vector)facets.get(key);
  -                } else {
  -                    throw new InvalidDatatypeFacetException("invalid facet tag : " + key);
  -                }
  -            }
  -            if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 )) {
  -                if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
  -                    throw new InvalidDatatypeFacetException(
  -                                                           "It is an error for both length and maxLength to be members of facets." );  
  -                } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
  -                    throw new InvalidDatatypeFacetException(
  -                                                           "It is an error for both length and minLength to be members of facets." );
  -                }
  -            }
  -
  -            if (( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
  -                                      DatatypeValidator.FACET_MAXLENGTH) ) != 0 )) {
  -                if (fMinLength > fMaxLength) {
  -                    throw new InvalidDatatypeFacetException( "Value of minLength = " + fMinLength +
  -                                                             "must be greater that the value of maxLength" + fMaxLength );
  -                }
  -            }
  -        }// End of Facets Setting
  +    // construct a list datatype validator
  +    public ListDatatypeValidator(DatatypeValidator itemDV) {
  +        fItemValidator = itemDV;
       }
   
  -
  -
  -
       /**
  -     * validate that a string is a W3C string type
  +     * Checks that "content" string is valid.
  +     * If invalid a Datatype validation exception is thrown.
        * 
  -     * @param content A string containing the content to be validated
  -     * @param list
  -     * @exception throws InvalidDatatypeException if the content is
  -     *                   not a W3C string type
  -     * @exception InvalidDatatypeValueException
  -     */
  -    public void validate(String content, Object state)  throws InvalidDatatypeValueException
  -    {
  -        checkContent( content, state );
  -    }
  -
  -
  -    /**
  -     * set the locate to be used for error messages
  -     */
  -    public void setLocale(Locale locale) {
  -        fLocale = locale;
  -    }
  -
  -
  -    /**
  -     * 
  -     * @return                          A Hashtable containing the facets
  -     *         for this datatype.
  -     */
  -    public Hashtable getFacets() {
  -        return null;
  -    }
  -
  -    public int compare( String content, String facetValue ) {
  -        // if derive by list then this should iterate through
  -        // the tokens in each string and compare using the base type
  -        // compare function.
  -        // if not derived by list just pass the compare down to the
  -        // base type.
  -        return 0;
  -    }
  -
  -    /**
  -   * Returns a copy of this object.
  -   */
  -    public Object clone() throws CloneNotSupportedException  {
  -        ListDatatypeValidator newObj = null;
  -        try {
  -            newObj = new ListDatatypeValidator();
  -
  -            newObj.fLocale           =  this.fLocale;
  -            newObj.fBaseValidator    =  this.fBaseValidator;
  -            newObj.fLength           =  this.fLength;
  -            newObj.fMaxLength        =  this.fMaxLength;
  -            newObj.fMinLength        =  this.fMinLength;
  -            newObj.fPattern          =  this.fPattern;
  -            newObj.fEnumeration      =  this.fEnumeration;
  -            newObj.fFacetsDefined    =  this.fFacetsDefined;
  -            newObj.fDerivedByList    =  this.fDerivedByList;
  -        } catch (InvalidDatatypeFacetException ex) {
  -            ex.printStackTrace();
  -        }
  -        return newObj;
  -    }
  -
  -    // Private methods
  -    private void checkContent( String content,  Object state )throws InvalidDatatypeValueException
  -    {
  -        StringTokenizer parsedList = new StringTokenizer( content );
  -        try {
  -            int numberOfTokens =  parsedList.countTokens();
  -            if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
  -                if (numberOfTokens > fMaxLength) {
  -                    throw new InvalidDatatypeValueException("Value '"+content+
  -                                                            "' with length ='"+  numberOfTokens + "' tokens"+
  -                                                            "' exceeds maximum length facet of '"+fMaxLength+"' tokens.");
  -                }
  -            }
  -            if ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
  -                if (numberOfTokens < fMinLength) {
  -                    throw new InvalidDatatypeValueException("Value '"+content+
  -                                                            "' with length ='"+ numberOfTokens+ "' tokens" +
  -                                                            "' is less than minimum length facet of '"+fMinLength+"' tokens." );
  -                }
  -            }
  -
  -            if ((fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
  -                if (numberOfTokens != fLength) {
  -                    throw new InvalidDatatypeValueException("Value '"+content+
  -                                                            "' with length ='"+ numberOfTokens+ "' tokens" +
  -                                                            "' is not equal to length facet of '"+fLength+"' tokens.");
  -                }
  -            }
  -
  -            if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
  -                // Enumerations are defined in the value space so the contains method
  -                // of vector doesn't really do the right thing, we really should check using compare
  -                if (fEnumeration.contains( content ) == false)
  -                    throw new InvalidDatatypeValueException("Value '"+
  -                                                            content+"' must be one of "+fEnumeration);
  -            }
  -            try {
  -                if (this.fDerivedByList) {
  -                    if( numberOfTokens == 0 ){
  -                        InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );
  -                        throw error;
  -                    }
  -                    while (parsedList.hasMoreTokens()) {       //Check each token in list against base type
  -                        if (this.fBaseValidator != null) {//validate against parent type if any
  -                            this.fBaseValidator.validate( parsedList.nextToken(), state );
  -                        }
  -                    }
  -                } else {
  -                    if (this.fBaseValidator != null) {//validate against parent type if any
  -                        this.fBaseValidator.validate( content, state );
  -                    }
  -                }
  -            } catch (InvalidDatatypeValueException ex) { //Keep bubbling up exception but change content to list content
  -                                                         //Unfortunately we need to throw a new Exception
  -                InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );//Need Message
  -                error.setKeyIntoReporter( ex.getKeyIntoReporter() );
  -                throw error;//type message repacked with the List content message
  -            }
  -
  -        } catch (NoSuchElementException e) {
  -            e.printStackTrace();
  -        }
  -    }
  -
  -    private void setBasetype( DatatypeValidator base) {
  -        fBaseValidator = base;
  -    }
  -
  -    /**
  -     * <P>Initializes the internal datattype state with documentInstance state information</P>
  -     * <P>This method should  be called before calling the
  -     * validate method</P>
  -     * 
  -     * @param documentInstanceState
  -     */
  -    public void initialize( Object documentInstanceState ) {
  -        if (fBaseValidator instanceof StatefullDatatypeValidator) {
  -            ((StatefullDatatypeValidator)fBaseValidator).initialize( documentInstanceState ); 
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
  +     * @see InvalidDatatypeValueException
  +     */
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +
  +        StringTokenizer parsedList = new StringTokenizer(content);
  +        int numberOfTokens =  parsedList.countTokens();
  +        if (numberOfTokens == 0) {
  +            throw new InvalidDatatypeValueException("EmptyList", null);
           }
  -    }
  -
  -    /**
  -     * <P>Initializes the internal datatype state 
  -     */
  -
  -    public void validate()throws InvalidDatatypeValueException {
  -        if ((fBaseValidator instanceof 
  -             org.apache.xerces.impl.dv.dtd.IDREFDatatypeValidator )) {
  -            ((StatefullDatatypeValidator)fBaseValidator).validate(); 
  +        //Check each token in list against base type
  +        while (parsedList.hasMoreTokens()) {
  +            this.fItemValidator.validate(parsedList.nextToken(), context);
           }
  -
       }
  -    /**
  -     * <P>This method returns some internal state of a statefull validator</P>
  -     * It returns a reference to the internal state
  -     *
  -     * @return  Object
  -     */
  -    public Object getInternalStateInformation() {
  -        Object value = null;
  -        if (fBaseValidator instanceof 
  -            org.apache.xerces.impl.dv.dtd.IDDatatypeValidator) {
  -            value = ((StatefullDatatypeValidator)fBaseValidator).getInternalStateInformation();
  -        }
  -        return value;
  -    }
  -
  -
   
   }
   
  
  
  
  1.3       +25 -39    xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/NMTOKENDatatypeValidator.java
  
  Index: NMTOKENDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/NMTOKENDatatypeValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NMTOKENDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.2
  +++ NMTOKENDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.3
  @@ -54,55 +54,41 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -package org.apache.xerces.impl.dv.dtd;
   
  -import java.util.Hashtable;
  +package org.apache.xerces.impl.dv.dtd;
   
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   import org.apache.xerces.util.XMLChar;
   
   /**
    * NMTOKEN datatype validator.
    *
  - * @version $Id: NMTOKENDatatypeValidator.java,v 1.2 2002/01/29 01:15:11 lehors Exp $
  + * @author Jeffrey Rodriguez, IBM
  + * @author Sandy Gao, IBM
  + * 
  + * @version $Id: NMTOKENDatatypeValidator.java,v 1.3 2002/02/15 16:00:29 sandygao Exp $
    */
  -public class NMTOKENDatatypeValidator 
  -    extends AbstractDatatypeValidator {
  -
  -   public  NMTOKENDatatypeValidator() throws InvalidDatatypeFacetException{
  -        // Native, No Facets defined, Restriction
  -      this( null, null, false );
  -
  -   }
  +public class NMTOKENDatatypeValidator implements DatatypeValidator {
   
  -   public NMTOKENDatatypeValidator( DatatypeValidator base, Hashtable facets, 
  -                                    boolean derivedByList ) throws InvalidDatatypeFacetException {
  -       // ignore everything -- just do NMTOKEN validation
  -   }
  -
  -   /**
  -    * validate that a string is a W3C string type
  -    * 
  -    * @param content A string containing the content to be validated
  -    * @param list
  -    * @exception throws InvalidDatatypeException if the content is
  -    *                   not a W3C string type
  -    * @exception InvalidDatatypeValueException
  -    */
  -   public void validate(String content, Object state)  
  -        throws InvalidDatatypeValueException {
  -       if (!XMLChar.isValidNmtoken(content)) {
  -           throw new InvalidDatatypeValueException(content+" is not a NMTOKEN");
  +    // construct a NMTOKEN datatype validator
  +    public NMTOKENDatatypeValidator() {
  +    }
  +
  +    /**
  +     * Checks that "content" string is valid NMTOKEN value.
  +     * If invalid a Datatype validation exception is thrown.
  +     * 
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
  +     * @see InvalidDatatypeValueException
  +     */
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +        if (!XMLChar.isValidNmtoken(content)) {
  +           throw new InvalidDatatypeValueException("NMTOKENInvalid", new Object[]{content});
          }
  -   }
  -
  -   public Hashtable getFacets() { return null; }
  -
  -   public int compare( String content, String facetValue){
  -       return content.compareTo(facetValue);
  -   }
  -
  -   public Object clone() throws CloneNotSupportedException  {
  -      return this;
      }
   
   } // class NMTOKENDatatypeValidator
  
  
  
  1.5       +17 -77    xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/NOTATIONDatatypeValidator.java
  
  Index: NOTATIONDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/NOTATIONDatatypeValidator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NOTATIONDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.4
  +++ NOTATIONDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.5
  @@ -55,98 +55,38 @@
    * <http://www.apache.org/>.
    */
   
  -
   package org.apache.xerces.impl.dv.dtd;
   
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Locale;
  -import java.util.StringTokenizer;
  -import org.apache.xerces.util.XMLChar;
  -import java.util.NoSuchElementException;
  -
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   
   /**
    * NOTATIONValidator defines the interface that data type validators must obey.
    * These validators can be supplied by the application writer and may be useful as
    * standalone code as well as plugins to the validator architecture.
    * 
  - * @author Jeffrey Rodriguez-
  - * @version $Id: NOTATIONDatatypeValidator.java,v 1.4 2002/01/29 01:15:11 lehors Exp $
  + * @author Jeffrey Rodriguez, IBM
  + * @author Sandy Gao, IBM
  + * 
  + * @version $Id: NOTATIONDatatypeValidator.java,v 1.5 2002/02/15 16:00:29 sandygao Exp $
    */
  - public class NOTATIONDatatypeValidator extends AbstractDatatypeValidator {
  -    private DatatypeValidator fBaseValidator = null;
  -
  -    public NOTATIONDatatypeValidator () throws InvalidDatatypeFacetException {
  -        this( null, null, false ); // Native, No Facets defined, Restriction
  + public class NOTATIONDatatypeValidator implements DatatypeValidator {
  + 
  +    // construct a NOTATION datatype validator
  +    public NOTATIONDatatypeValidator() {
       }
   
  -    public NOTATIONDatatypeValidator ( DatatypeValidator base, Hashtable facets, 
  -         boolean derivedByList ) throws InvalidDatatypeFacetException {
  -         setBasetype( base ); // Set base type 
  -    }
  -
  -
       /**
  -     * Checks that "content" string is valid 
  -     * datatype.
  +     * Checks that "content" string is valid NOTATION value.
        * If invalid a Datatype validation exception is thrown.
        * 
  -     * @param content A string containing the content to be validated
  -     * @param derivedBylist
  -     *                Flag which is true when type
  -     *                is derived by list otherwise it
  -     *                it is derived by extension.
  -     *                
  -     * @exception throws InvalidDatatypeException if the content is
  -     *                   invalid according to the rules for the validators
  -     * @exception InvalidDatatypeValueException
  -     * @see        InvalidDatatypeValueException
  -     */
  -    public void validate(String content, Object state ) throws InvalidDatatypeValueException{
  -    }
  -
  -    public Hashtable getFacets(){
  -        return null;
  -    }
  -
  -
  -
  -    /**
  -    * set the locate to be used for error messages
  -    */
  -    public void setLocale(Locale locale){
  -    }
  -
  -    /**
  -     * REVISIT
  -     * Compares two Datatype for order
  -     * 
  -     * @param o1
  -     * @param o2
  -     * @return 0 if value1 and value2 are equal, a value less than 0 if value1 is less than value2, a value greater than 0 if value1 is greater than value2
  -     */
  -    public int compare( String content1, String content2){
  -        return -1;
  -    }
  -  /**
  -     * Returns a copy of this object.
  -     */
  -    public Object clone() throws CloneNotSupportedException {
  -        throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
  -    }
  -
  -    /**
  -     * Name of base type as a string.
  -     * A Native datatype has the string "native"  as its
  -     * base type.
  -     * 
  -     * @param base   the validator for this type's base type
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
  +     * @see InvalidDatatypeValueException
        */
  -
  -    private void setBasetype(DatatypeValidator base){
  -        fBaseValidator = base;
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
       }
  -
   
   }
  
  
  
  1.3       +22 -325   xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/StringDatatypeValidator.java
  
  Index: StringDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/StringDatatypeValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringDatatypeValidator.java	29 Jan 2002 01:15:11 -0000	1.2
  +++ StringDatatypeValidator.java	15 Feb 2002 16:00:29 -0000	1.3
  @@ -54,18 +54,11 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -package org.apache.xerces.impl.dv.dtd;
  -
  -import java.util.Hashtable;
  -import java.util.Vector;
  -import java.util.Enumeration;
  -import java.util.Locale;
  -import java.text.Collator;
  -import java.util.Enumeration;
  -import java.util.StringTokenizer;
  -import java.util.NoSuchElementException;
   
  +package org.apache.xerces.impl.dv.dtd;
   
  +import org.apache.xerces.impl.validation.ValidationContext;
  +import org.apache.xerces.impl.dv.*;
   
   /**
    * <P>StringValidator validates that XML content is a W3C string type.</P>
  @@ -79,321 +72,25 @@
    * character has a corresponding Universal Code Set
    * code point ([ISO 10646],[Unicode] and [Unicode3]),
    * which is an integer.</P>
  - * @version $Id: StringDatatypeValidator.java,v 1.2 2002/01/29 01:15:11 lehors Exp $
  + * @version $Id: StringDatatypeValidator.java,v 1.3 2002/02/15 16:00:29 sandygao Exp $
    */
  -public class StringDatatypeValidator extends AbstractDatatypeValidator {
  -private Locale     fLocale          = null;
  -   DatatypeValidator  fBaseValidator   = null; // Native datatypes have null
  -
  -   private int        fLength           = 0;
  -   private int        fMaxLength        = Integer.MAX_VALUE;
  -   private int        fMinLength        = 0;
  -   private String     fPattern          = null;
  -   private Vector     fEnumeration      = null;
  -   private short      fWhiteSpace       = DatatypeValidator.WHITESPACE_NONE;
  -
  -
  -   /* per Schema CR
  -   private String     fMaxInclusive     = null;
  -   private String     fMaxExclusive     = null;
  -   private String     fMinInclusive     = null;
  -   private String     fMinExclusive     = null;
  -   */
  -   private int        fFacetsDefined    = 0;
  -
  -   private boolean    isMaxExclusiveDefined = false;
  -   private boolean    isMaxInclusiveDefined = false;
  -   private boolean    isMinExclusiveDefined = false;
  -   private boolean    isMinInclusiveDefined = false;
  -   //private RegularExpression fRegex         = null;
  -
  -
  -
  -
  -
  -   public  StringDatatypeValidator () throws InvalidDatatypeFacetException{
  -      this( null, null, false ); // Native, No Facets defined, Restriction
  -
  -   }
  -
  -   public StringDatatypeValidator ( DatatypeValidator base, Hashtable facets, 
  -                                    boolean derivedByList ) throws InvalidDatatypeFacetException {
  -
  -      setBasetype( base ); // Set base type 
  -
  -
  -      // Set Facets if any defined
  -      //fFacetsDefined = 0;
  -      if ( facets != null  ) {
  -         for (Enumeration e = facets.keys(); e.hasMoreElements();) {
  -            String key = (String) e.nextElement();
  -
  -            if ( key.equals("length") ) {
  -               fFacetsDefined += DatatypeValidator.FACET_LENGTH;
  -               String lengthValue = (String)facets.get(key);
  -               try {
  -                  fLength     = Integer.parseInt( lengthValue );
  -               } catch (NumberFormatException nfe) {
  -                  throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
  -               }
  -               if ( fLength < 0 )
  -                  throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"'  must be a nonNegativeInteger.");
  -
  -            } else if (key.equals("minlength") ) {
  -               fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
  -               String minLengthValue = (String)facets.get(key);
  -               try {
  -                  fMinLength     = Integer.parseInt( minLengthValue );
  -               } catch (NumberFormatException nfe) {
  -                  throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' is invalid.");
  -               }
  -            } else if (key.equals("maxlength") ) {
  -               fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
  -               String maxLengthValue = (String)facets.get(key);
  -               try {
  -                  fMaxLength     = Integer.parseInt( maxLengthValue );
  -               } catch (NumberFormatException nfe) {
  -                  throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
  -               }
  -            } 
  -            /***
  -            else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
  -               fFacetsDefined += DatatypeValidator.FACET_PATTERN;
  -               fPattern = (String)facets.get(key);
  -               fRegex   = new RegularExpression(fPattern, "X");
  -            } 
  -            /***/
  -            else if (key.equals("enumeration")) {
  -               fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
  -               fEnumeration = (Vector)facets.get(key);
  -               /* Per Schema CR - October 23 spec we don't have this facets in String datatype
  -           } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
  -               fFacetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
  -               fMaxInclusive = (String)facets.get(key);
  -           } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
  -               fFacetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
  -               fMaxExclusive = (String)facets.get(key);
  -           } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
  -               fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
  -               fMinInclusive = (String)facets.get(key);
  -           } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
  -               fFacetsDefined += DatatypeValidator.FACET_MINEXCLUSIVE;
  -               fMinExclusive = (String)facets.get(key);
  -               */
  -            } else if (key.equals("whitespace")) {
  -               String         whiteSpaceChoice = (String)facets.get(key); 
  -               fFacetsDefined += DatatypeValidator.FACET_WHITESPACE;
  -               if ( whiteSpaceChoice.equals("preserve" ) ) {
  -                  fWhiteSpace = DatatypeValidator.WHITESPACE_PRESERVE;
  -               } else if ( whiteSpaceChoice.equals("replace") ) {
  -                  fWhiteSpace = DatatypeValidator.WHITESPACE_REPLACE;
  -               } else if ( whiteSpaceChoice.equals("collapse") ) {
  -                  fWhiteSpace = DatatypeValidator.WHITESPACE_COLLAPSE;
  -               }
  -            } else {
  -               throw new InvalidDatatypeFacetException("invalid facet tag : " + key);
  -            }
  -         }
  -
  -         if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
  -            if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
  -               throw new InvalidDatatypeFacetException(
  -                                                      "It is an error for both length and maxLength to be members of facets." );  
  -            } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
  -               throw new InvalidDatatypeFacetException(
  -                                                      "It is an error for both length and minLength to be members of facets." );
  -            }
  -         }
  -
  -         if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
  -                                    DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
  -            if ( fMinLength > fMaxLength ) {
  -               throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
  -                                                        "'must be less than the value of maxLength = '" + fMaxLength + "'.");
  -            }
  -         }
  -
  -         isMaxExclusiveDefined = ((fFacetsDefined & 
  -                                   DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
  -         isMaxInclusiveDefined = ((fFacetsDefined & 
  -                                   DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
  -         isMinExclusiveDefined = ((fFacetsDefined &
  -                                   DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
  -         isMinInclusiveDefined = ((fFacetsDefined &
  -                                   DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;
  -
  -         if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
  -            throw new InvalidDatatypeFacetException(
  -                                                   "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." ); 
  -         }
  -         if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
  -            throw new InvalidDatatypeFacetException(
  -                                                   "It is an error for both minInclusive and minExclusive to be specified for the same datatype." ); 
  -         }
  -
  -      }// End of Facets Setting
  -   }
  -
  -
  -
  -
  -   /**
  -    * validate that a string is a W3C string type
  -    * 
  -    * @param content A string containing the content to be validated
  -    * @param list
  -    * @exception throws InvalidDatatypeException if the content is
  -    *                   not a W3C string type
  -    * @exception InvalidDatatypeValueException
  -    */
  -   public void validate(String content, Object state)  throws InvalidDatatypeValueException
  -   {
  -      checkContent( content, state );
  -   }
  -
  -
  -   /**
  -    * set the locate to be used for error messages
  -    */
  -   public void setLocale(Locale locale) {
  -      fLocale = locale;
  -   }
  -
  -
  -   /**
  -    * 
  -    * @return                          A Hashtable containing the facets
  -    *         for this datatype.
  -    */
  -   public Hashtable getFacets(){
  -      return null;
  -   }
  -
  -   private void checkContent( String content, Object state )throws InvalidDatatypeValueException
  -   {
  -
  -      if ( this.fBaseValidator != null ) {//validate against parent type if any
  -         this.fBaseValidator.validate( content, state );
  -      }
  -
  -      if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
  -         if ( content.length() > fMaxLength ) {
  -            throw new InvalidDatatypeValueException("Value '"+content+
  -                                                    "' with length '"+content.length()+
  -                                                    "' exceeds maximum length facet of '"+fMaxLength+"'.");
  -         }
  -      }
  -      if ( (fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
  -         if ( content.length() < fMinLength ) {
  -            throw new InvalidDatatypeValueException("Value '"+content+
  -                                                    "' with length '"+content.length()+
  -                                                    "' is less than minimum length facet of '"+fMinLength+"'." );
  -         }
  -      }
  -
  -      if ( (fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0 ) {
  -         if ( content.length() != fLength ) {
  -            throw new InvalidDatatypeValueException("Value '"+content+
  -                                                    "' with length '"+content.length()+
  -                                                    "' is not equal to length facet '"+fLength+"'.");
  -         }
  -      }
  -
  -
  -
  -      if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 ) {
  -         if ( fEnumeration.contains( content ) == false )
  -            throw new InvalidDatatypeValueException("Value '"+content+"' must be one of "+fEnumeration);
  -      }
  -      /*  Per October 23 CR - facets don't apply to StringValidator
  -      if ( isMaxExclusiveDefined == true ) {
  -          int comparisonResult;
  -          comparisonResult  = compare( content, fMaxExclusive );
  -          if ( comparisonResult >= 0 ) {
  -              throw new InvalidDatatypeValueException( "MaxExclusive:Value '"+content+ "'  must be " +
  -                                                       "lexicographically less than" + fMaxExclusive );
  -
  -          }
  -
  -      }
  -      if ( isMaxInclusiveDefined == true ) {
  -          int comparisonResult;
  -          comparisonResult  = compare( content, fMaxInclusive );
  -          if ( comparisonResult > 0 )
  -              throw new InvalidDatatypeValueException( "MaxInclusive:Value '"+content+ "' must be " +
  -                                                       "lexicographically less or equal than" + fMaxInclusive );
  -      }
  -
  -      if ( isMinExclusiveDefined == true ) {
  -          int comparisonResult;
  -          comparisonResult  = compare( content, fMinExclusive );
  -
  -          //System.out.println( "exclusive = " + comparisonResult );
  -
  -          if ( comparisonResult <= 0 )
  -              throw new InvalidDatatypeValueException( "MinExclusive:Value '"+content+ "' must be " +
  -                                                       "lexicographically greater than" + fMinExclusive );
  -      }
  -      if ( isMinInclusiveDefined == true ) {
  -          int comparisonResult;
  -          comparisonResult = compare( content, fMinInclusive );
  -          //System.out.println( "inclusive = " + comparisonResult );
  -          if ( comparisonResult < 0 )
  -              throw new InvalidDatatypeValueException( "MinInclusive:Value '"+content+ "' must be " +
  -                                                       "lexicographically greater or equal than '" + fMinInclusive  + "'." );
  -      }
  -
  -        */
  -
  -      /***
  -      if ( (fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
  -         //RegularExpression regex = new RegularExpression(fPattern );
  -         if ( fRegex == null || fRegex.matches( content) == false )
  -            throw new InvalidDatatypeValueException("Value '"+content+
  -                                                    "' does not match regular expression facet '" + fPattern + "'." );
  -      }
  -      /***/
  -
  -   }
  -   public int compare( String content, String facetValue ){
  -      Locale    loc       = Locale.getDefault();
  -      Collator  collator  = Collator.getInstance( loc );
  -      return collator.compare( content, facetValue );
  -   }
  -
  -   /**
  -  * Returns a copy of this object.
  -  */
  -   public Object clone() throws CloneNotSupportedException  {
  -      StringDatatypeValidator newObj = null;
  -      try {
  -         newObj = new StringDatatypeValidator();
  -
  -         newObj.fLocale           =  this.fLocale;
  -         newObj.fBaseValidator    =  this.fBaseValidator;
  -         newObj.fLength           =  this.fLength;
  -         newObj.fMaxLength        =  this.fMaxLength;
  -         newObj.fMinLength        =  this.fMinLength;
  -         newObj.fPattern          =  this.fPattern;
  -         newObj.fEnumeration      =  this.fEnumeration;
  -         /* October 23 - per XML Datatype Spec 
  -         newObj.fMaxInclusive     =  this.fMaxInclusive;
  -         newObj.fMaxExclusive     =  this.fMaxExclusive;
  -         newObj.fMinInclusive     =  this.fMinInclusive;
  -         newObj.fMinExclusive     =  this.fMinExclusive;
  -         */
  -         newObj.fFacetsDefined    =  this.fFacetsDefined;
  -         newObj.isMaxExclusiveDefined = this.isMaxExclusiveDefined;
  -         newObj.isMaxInclusiveDefined = this.isMaxInclusiveDefined;
  -         newObj.isMinExclusiveDefined = this.isMinExclusiveDefined;
  -         newObj.isMinInclusiveDefined = this.isMinInclusiveDefined;
  -      } catch ( InvalidDatatypeFacetException ex) {
  -         ex.printStackTrace();
  -      }
  -      return newObj;
  -   }
  +public class StringDatatypeValidator implements DatatypeValidator {
   
  -   private void setBasetype( DatatypeValidator base) {
  -      fBaseValidator = base;
  -   }
  +    // construct a string datatype validator
  +    public StringDatatypeValidator() {
  +    }
  +
  +    /**
  +     * Checks that "content" string is valid string value.
  +     * If invalid a Datatype validation exception is thrown.
  +     * 
  +     * @param content       the string value that needs to be validated
  +     * @param context       the validation context
  +     * @throws InvalidDatatypeException if the content is
  +     *         invalid according to the rules for the validators
  +     * @see InvalidDatatypeValueException
  +     */
  +    public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
  +    }
  +    
   }
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/impl/dv/dtd/DTDDVFactoryImpl.java
  
  Index: DTDDVFactoryImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001, 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.impl.dv.dtd;
  
  import org.apache.xerces.impl.dv.DTDDVFactory;
  import org.apache.xerces.impl.dv.DatatypeValidator;
  import java.util.Hashtable;
  
  /**
   * the factory to create/return built-in schema DVs and create user-defined DVs
   *
   * @author Sandy Gao, IBM
   *
   * @version $Id: DTDDVFactoryImpl.java,v 1.1 2002/02/15 16:00:29 sandygao Exp $
   */
  public class DTDDVFactoryImpl extends DTDDVFactory {
  
      static Hashtable fBuiltInTypes = null;
  
      /**
       * return a dtd type of the given name
       *
       * @param name  the name of the datatype
       * @return      the datatype validator of the given name
       */
      public DatatypeValidator getBuiltInDV(String name) {
          prepareBuiltInTypes();
          return (DatatypeValidator)fBuiltInTypes.get(name);
      }
  
      /**
       * get all built-in DVs, which are stored in a hashtable keyed by the name
       *
       * @return      a hashtable which contains all datatypes
       */
      public Hashtable getBuiltInTypes() {
          prepareBuiltInTypes();
          return (Hashtable)fBuiltInTypes.clone();
      }
  
      // make sure the built-in types are created
      // the types are supposed to be reused for all factory objects,
      // so we synchorinize on the class object.
      void prepareBuiltInTypes() {
          if (fBuiltInTypes == null) {
              synchronized (this.getClass()) {
                  // check again, in case I'm waiting for another thread to create
                  // the types.
                  if (fBuiltInTypes == null) {
                      createBuiltInTypes();
                  }
              }
          }
      }
  
      // create all built-in types
      // we are assumeing that fBuiltInTypes == null
      void createBuiltInTypes() {
  
          fBuiltInTypes = new Hashtable();
          DatatypeValidator dvTemp;
          
          fBuiltInTypes.put("string", new StringDatatypeValidator());
          fBuiltInTypes.put("ID", new IDDatatypeValidator());
          dvTemp = new IDREFDatatypeValidator();
          fBuiltInTypes.put("IDREF", dvTemp);
          fBuiltInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
          dvTemp = new ENTITYDatatypeValidator();
          fBuiltInTypes.put("ENTITY", new ENTITYDatatypeValidator());
          fBuiltInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
          fBuiltInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
          dvTemp = new NMTOKENDatatypeValidator();
          fBuiltInTypes.put("NMTOKEN", dvTemp);
          fBuiltInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
          
      }//createBuiltInTypes()
  
  }//SchemaDVFactory
  
  
  
  1.3       +2 -2      xml-xerces/java/src/org/apache/xerces/impl/dv/xs/EntityDV.java
  
  Index: EntityDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/EntityDV.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EntityDV.java	29 Jan 2002 01:15:12 -0000	1.2
  +++ EntityDV.java	15 Feb 2002 16:00:30 -0000	1.3
  @@ -67,7 +67,7 @@
    * @author Neeraj Bajaj, Sun Microsystems, inc.
    * @author Sandy Gao, IBM
    *
  - * @version $Id: EntityDV.java,v 1.2 2002/01/29 01:15:12 lehors Exp $
  + * @version $Id: EntityDV.java,v 1.3 2002/02/15 16:00:30 sandygao Exp $
    */
   public class EntityDV extends TypeValidator {
   
  @@ -84,7 +84,7 @@
       }
   
       public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException {
  -        if (!context.isEntityDeclared((String)value)) {
  +        if (!context.isEntityUnparsed((String)value)) {
               throw new InvalidDatatypeValueException("UndeclaredEntity", new Object[]{value});
           }
       }
  
  
  
  1.7       +26 -25    xml-xerces/java/src/org/apache/xerces/impl/msg/XMLMessages.properties
  
  Index: XMLMessages.properties
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLMessages.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLMessages.properties	29 Jan 2002 13:52:15 -0000	1.6
  +++ XMLMessages.properties	15 Feb 2002 16:00:30 -0000	1.7
  @@ -5,9 +5,9 @@
   
           BadMessageKey = The error message corresponding to the message key can not be found.
           FormatFailed = An internal error occurred while formatting the following message:\n  
  -	
  +        
   # Document messages
  -	PrematureEOF=Premature end of file.
  +        PrematureEOF=Premature end of file.
   # 2.1 Well-Formed XML Documents
           RootElementRequired = The root element is required in a well-formed document.
   # 2.2 Characters
  @@ -32,13 +32,13 @@
           SpaceRequiredBeforeStandalone = White space is required before the encoding pseudo attribute in the XML declaration.
           MarkupNotRecognizedInProlog = The markup in the document preceding the root element must be well-formed.
           MarkupNotRecognizedInMisc = The markup in the document following the root element must be well-formed.
  -	AlreadySeenDoctype = Already seen doctype.
  -	ContentIllegalInProlog = Content is not allowed in prolog.
  -	ReferenceIllegalInProlog = Reference is not allowed in prolog.
  +        AlreadySeenDoctype = Already seen doctype.
  +        ContentIllegalInProlog = Content is not allowed in prolog.
  +        ReferenceIllegalInProlog = Reference is not allowed in prolog.
   # Trailing Misc
  -	ContentIllegalInTrailingMisc=Content is not allowed in trailing section.
  -	ReferenceIllegalInTrailingMisc=Reference is not allowed in trailing section.
  -	
  +        ContentIllegalInTrailingMisc=Content is not allowed in trailing section.
  +        ReferenceIllegalInTrailingMisc=Reference is not allowed in trailing section.
  +        
   # 2.9 Standalone Document Declaration
           SDDeclInvalid = The standalone document declaration value must be \"yes\" or \"no\", not \"{0}\".
   # 2.12 Language Identification
  @@ -48,20 +48,20 @@
   # 3.1 Start-Tags, End-Tags, and Empty-Element Tags
           ElementUnterminated = Element type \"{0}\" must be followed by either attribute specifications, \">\" or \"/>\".
           EqRequiredInAttribute = Attribute name \"{0}\" must be followed by the '' = '' character.
  -	OpenQuoteExpected = Open quote is expected for attribute \"{0}|\".
  -	CloseQuoteExpected = Close quote is expected for attribute \"{0}|\".
  +        OpenQuoteExpected = Open quote is expected for attribute \"{0}|\".
  +        CloseQuoteExpected = Close quote is expected for attribute \"{0}|\".
           AttributeNotUnique = Attribute \"{1}\" was already specified for element \"{0}\".
           AttributeNSNotUnique = Attribute \"{1}\" bound to namespace \"{2}\" was already specified for element \"{0}\".
           ETagUnterminated = The end-tag for element type \"{0}\" must end with a ''>'' delimiter.
           MarkupNotRecognizedInContent = The content of elements must consist of well-formed character data or markup.
  -	DoctypeIllegalInContent = doctype not allowed in content.
  +        DoctypeIllegalInContent = doctype not allowed in content.
   # 4.1 Character and Entity References
           ReferenceUnterminated = The reference must be terminated by a ';' delimiter.
   # 4.3.2 Well-Formed Parsed Entities
           ReferenceNotInOneEntity = The reference must be entirely contained within the same parsed entity.
           ElementEntityMismatch = The element \"{0}\" must start and end within the same entity.
  -	MarkupEntityMismatch=XML document structures must start and end within the same entity.
  -	
  +        MarkupEntityMismatch=XML document structures must start and end within the same entity.
  +        
   # Messages common to Document and DTD
   # 2.2 Characters
           InvalidCharInAttValue = An invalid XML character (Unicode: 0x{2}) was found in the value of attribute \"{1}\".
  @@ -77,13 +77,13 @@
           InvalidCommentStart = Comment must start with \"<!--\".
           DashDashInComment = The string \"--\" is not permitted within comments.
           CommentUnterminated = The comment must end with \"-->\".
  -	COMMENT_NOT_IN_ONE_ENTITY = The comment is not enclosed xin the same entity.
  +        COMMENT_NOT_IN_ONE_ENTITY = The comment is not enclosed xin the same entity.
   # 2.6 Processing Instructions
           PITargetRequired = The processing instruction must begin with the name of the target.
           SpaceRequiredInPI = White space is required between the processing instruction target and data.
           PIUnterminated = The processing instruction must end with \"?>\".
           ReservedPITarget = The processing instruction target matching \"[xX][mM][lL]\" is not allowed.
  -	PI_NOT_IN_ONE_ENTITY = The processing instruction is not enclosed in the same entity.
  +        PI_NOT_IN_ONE_ENTITY = The processing instruction is not enclosed in the same entity.
   # 2.8 Prolog and Document Type Declaration
           VersionInfoInvalid = Invalid version \"{0}\".
           VersionNotSupported = XML version \"{0}\" is not supported, only XML 1.0 is supported.
  @@ -103,16 +103,16 @@
           SpaceRequiredBeforeEncodingInTextDecl = White space is required before the encoding pseudo attribute in the text declaration.
           TextDeclUnterminated = The text declaration must end with \"?>\".
           EncodingDeclRequired = The encoding declaration is required in the text declaration.
  -	NoMorePseudoAttributes = no more pseudo attributes is allowed.
  -	MorePseudoAttributes = more pseudo attributes is expected.
  -	PseudoAttrNameExpected = a pseudo attribute name is expected. 
  +        NoMorePseudoAttributes = no more pseudo attributes is allowed.
  +        MorePseudoAttributes = more pseudo attributes is expected.
  +        PseudoAttrNameExpected = a pseudo attribute name is expected. 
   # 4.3.2 Well-Formed Parsed Entities
           CommentNotInOneEntity = The comment must be entirely contained within the same parsed entity.
           PINotInOneEntity = The processing instruction must be entirely contained within the same parsed entity.
   # 4.3.3 Character Encoding in Entities
           EncodingDeclInvalid = Invalid encoding name \"{0}\".
           EncodingByteOrderUnsupported = Given byte order for encoding \"{0}\" is not supported.
  -	
  +        
   # DTD Messages
   # 2.2 Characters
           InvalidCharInEntityValue = An invalid XML character (Unicode: 0x{0}) was found in the literal entity value.
  @@ -188,7 +188,7 @@
           ExternalIDRequired = The external entity declaration must begin with either \"SYSTEM\" or \"PUBLIC\".
           MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID = White space is required between \"PUBLIC\" and the public identifier.
           MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID = White space is required between the public identifier and the system identifier.
  -	MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID = White space is required between \"SYSTEM\" and the system identifier.
  +        MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID = White space is required between \"SYSTEM\" and the system identifier.
           MSG_URI_FRAGMENT_IN_SYSTEMID = The fragment identifier should not be specified as part of the system identifier \"{0}\".
   # 4.7 Notation Declarations
           MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL = White space is required after \"<!NOTATION\" in the notation declaration.
  @@ -196,7 +196,7 @@
           MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL = White space is required after the notation name \"{0}\" in the notation declaration.
           ExternalIDorPublicIDRequired = The declaration for the notation \"{0}\" must include a system or public identifier.
           NotationDeclUnterminated = The declaration for the notation \"{0}\" must end with ''>''.
  -	
  +        
   # Validation messages
           DuplicateTypeInMixedContent = The element type \"{1}\" was already specified in the content model of the element decl \"{0}\".
           ENTITIESInvalid = Attribute value \"{1}\" of type ENTITIES must be the names of one or more unparsed entities.
  @@ -235,6 +235,7 @@
           ENTITYFailedInitializeGrammar =  ENTITYDatatype Validator: Failed Need to call initialize method with a valid Grammar reference. 	
           ENTITYNotUnparsed = ENTITY \"{0}\" is not unparsed.
           ENTITYNotValid = ENTITY \"{0}\" is not valid.
  +        EmptyList = Value of type ENTITIES, IDREFS, and NMTOKENS cannot be empty list.
   
   # Entity related messages
   # 3.1 Start-Tags, End-Tags, and Empty-Element Tags
  @@ -248,16 +249,16 @@
   # 4.3.3 Character Encoding in Entities
           EncodingNotSupported = The encoding \"{0}\" is not supported.
           EncodingRequired = A parsed entity not encoded in either UTF-8 or UTF-16 must contain an encoding declaration.
  -	
  +        
   # Namespaces support
   # 4. Using Qualified Names
           ElementPrefixUnbound = The prefix \"{0}\" for element \"{1}\" is not bound.
           AttributePrefixUnbound = The prefix \"{0}\" for attribute \"{1}\" is not bound.
  -	EmptyPrefixedAttName = The value of the attribute \"{0}\" is invalid. Prefixed namespace bindings may not be empty.
  +        EmptyPrefixedAttName = The value of the attribute \"{0}\" is invalid. Prefixed namespace bindings may not be empty.
           PrefixDeclared = The namespace prefix \"{0}\" was not declared.
           MSG_ATT_DEFAULT_INVALID = The defaultValue \"{1}\" of attribute \"{0}\" is not legal as for the lexical constraints of this attribute type.
   
   # REVISIT: These need messages
           MSG_SPACE_REQUIRED_AFTER_SYSTEMLITERAL_IN_EXTERNALID=MSG_SPACE_REQUIRED_AFTER_SYSTEMLITERAL_IN_EXTERNALID
  -	OpenQuoteMissingInDecl=OpenQuoteMissingInDecl
  -	InvalidCharInLiteral=InvalidCharInLiteral
  +        OpenQuoteMissingInDecl=OpenQuoteMissingInDecl
  +        InvalidCharInLiteral=InvalidCharInLiteral
  
  
  
  1.4       +18 -7     xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationManager.java
  
  Index: ValidationManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValidationManager.java	29 Jan 2002 01:15:13 -0000	1.3
  +++ ValidationManager.java	15 Feb 2002 16:00:30 -0000	1.4
  @@ -59,6 +59,7 @@
   
   import org.apache.xerces.impl.validation.ValidationState;
   import org.apache.xerces.xni.parser.XMLComponent;
  +import java.util.Vector;
   
   /**
    * ValidationManager is a coordinator property for validators in the 
  @@ -71,14 +72,26 @@
    */
   public class ValidationManager {
   
  -    // REVISIT: should validation/state be another property?
  -    protected final ValidationState fValidationState= new ValidationState();
  +    protected final Vector fVSs = new Vector();
       protected boolean fGrammarFound = false;
   
  -    public ValidationState getValidationState (){
  -        return fValidationState;
  +    /**
  +     * Each validator should call this method to add its ValidationState into
  +     * the validation manager.
  +     */
  +    public void addValidationState(ValidationState vs) {
  +        fVSs.addElement(vs);
       }
   
  +    /**
  +     * Set the information required to validate entity values.
  +     */
  +    public void setEntityState(EntityState state) {
  +        for (int i = fVSs.size()-1; i >= 0; i--) {
  +            ((ValidationState)fVSs.elementAt(i)).setEntityState(state);
  +        }
  +    }
  +    
       public void setGrammarFound(boolean grammar){
           fGrammarFound = grammar;
       }
  @@ -96,9 +109,7 @@
       // public void setLastValidationComponent( XMLComponent validator){
           
       public void reset (){
  -        fValidationState.reset();
  +        fVSs.removeAllElements();
           fGrammarFound = false;
       }
   }
  -
  -
  
  
  
  1.9       +8 -4      xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationState.java
  
  Index: ValidationState.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/ValidationState.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ValidationState.java	29 Jan 2002 01:15:13 -0000	1.8
  +++ ValidationState.java	15 Feb 2002 16:00:30 -0000	1.9
  @@ -68,7 +68,7 @@
    * environment for simple type validation.
    *
    * @author Elena Litani, IBM
  - * @version $Id: ValidationState.java,v 1.8 2002/01/29 01:15:13 lehors Exp $
  + * @version $Id: ValidationState.java,v 1.9 2002/02/15 16:00:30 sandygao Exp $
    */
   public class ValidationState implements ValidationContext {
   
  @@ -115,17 +115,21 @@
           fSymbolTable = sTable;
       }
   
  -    public boolean checkIDRefID () {
  +    /**
  +     * return null if all IDREF values have a corresponding ID value;
  +     * otherwise return the first IDREF value without a matching ID value.
  +     */
  +    public String checkIDRefID () {
           Enumeration en = fIdRefTable.keys();
   
           String key;
           while (en.hasMoreElements()) {
               key = (String)en.nextElement();
               if (!fIdTable.containsKey(key)) {
  -                  return false;
  +                  return key;
               }
           }
  -        return true;
  +        return null;
       }
   
       public void reset () {
  
  
  
  1.42      +7 -13     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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- XMLSchemaValidator.java	3 Feb 2002 18:07:46 -0000	1.41
  +++ XMLSchemaValidator.java	15 Feb 2002 16:00:30 -0000	1.42
  @@ -130,7 +130,7 @@
    * @author Elena Litani IBM
    * @author Andy Clark IBM
    * @author Neeraj Bajaj, Sun Microsystems, inc.
  - * @version $Id: XMLSchemaValidator.java,v 1.41 2002/02/03 18:07:46 edwingo Exp $
  + * @version $Id: XMLSchemaValidator.java,v 1.42 2002/02/15 16:00:30 sandygao Exp $
    */
   public class XMLSchemaValidator
                implements XMLComponent, XMLDocumentFilter, FieldActivator {
  @@ -192,8 +192,6 @@
       protected static final String VALIDATION_MANAGER =
       Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
   
  -    // REVISIT: this is just a temporary solution for entity resolver
  -    //          while we are making a decision
       protected static final String ENTITY_MANAGER =
       Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
   
  @@ -350,7 +348,7 @@
   
       // updated during reset
       protected ValidationManager fValidationManager = null;
  -    protected ValidationState fValidationState = null;
  +    protected ValidationState fValidationState = new ValidationState();
       protected XMLGrammarPool fGrammarPool;
   
       // schema location property values
  @@ -1142,14 +1140,15 @@
               fSchemaElementDefault = false;
           }
   
  -        // REVISIT: use default entity resolution from ENTITY MANAGER - temporary solution
           fEntityResolver = (XMLEntityResolver)componentManager.getProperty(ENTITY_MANAGER);
   
           // initialize namespace support
           fNamespaceSupport.reset(fSymbolTable);
           fPushForNextBinding = true;
  -        fValidationManager= (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
  -        fValidationManager.reset();
  +        fValidationManager = (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
  +        fValidationManager.addValidationState(fValidationState);
  +        fValidationState.setNamespaceSupport(fNamespaceSupport);
  +        fValidationState.setSymbolTable(fSymbolTable);
   
           // get schema location properties
           fExternalSchemas = (String)componentManager.getProperty(SCHEMA_LOCATION);
  @@ -1575,11 +1574,6 @@
               // thus we will not validate in the case dynamic feature is on or we found dtd grammar
               fDoValidation = fValidation && !(fValidationManager.isGrammarFound() || fDynamicValidation);
   
  -            // REVISIT: why don't we do it in reset()?
  -            fValidationState = fValidationManager.getValidationState();
  -            fValidationState.setNamespaceSupport(fNamespaceSupport);
  -            fValidationState.setSymbolTable(fSymbolTable);
  -
               // parse schemas specified via schema location properties
               parseSchemas(fExternalSchemas, fExternalNoNamespaceSchema);
           }
  @@ -1935,7 +1929,7 @@
   
               if (fDoValidation) {
                   // 7 If the element information item is the validation root, it must be valid per Validation Root Valid (ID/IDREF) (3.3.4).
  -                if (!fValidationState.checkIDRefID()) {
  +                if (fValidationState.checkIDRefID() != null) {
                       reportSchemaError("ValidationRoot", null);
                   }
               }
  
  
  
  1.20      +5 -6      xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java
  
  Index: StandardParserConfiguration.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/StandardParserConfiguration.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- StandardParserConfiguration.java	3 Feb 2002 18:07:46 -0000	1.19
  +++ StandardParserConfiguration.java	15 Feb 2002 16:00:30 -0000	1.20
  @@ -69,8 +69,7 @@
   import org.apache.xerces.impl.XMLNamespaceBinder;
   import org.apache.xerces.impl.msg.XMLMessageFormatter;
   import org.apache.xerces.impl.validation.ValidationManager;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactory;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactoryImpl;
  +import org.apache.xerces.impl.dv.DTDDVFactory;
   import org.apache.xerces.xni.grammars.XMLGrammarPool;
   import org.apache.xerces.impl.validation.XMLGrammarPoolImpl;
   
  @@ -122,7 +121,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: StandardParserConfiguration.java,v 1.19 2002/02/03 18:07:46 edwingo Exp $
  + * @version $Id: StandardParserConfiguration.java,v 1.20 2002/02/15 16:00:30 sandygao Exp $
    */
   public class StandardParserConfiguration
       extends BasicParserConfiguration 
  @@ -229,7 +228,7 @@
       protected XMLGrammarPool fGrammarPool;
   
       /** Datatype validator factory. */
  -    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
  +    protected DTDDVFactory fDatatypeValidatorFactory;
   
       // components (configurable)
   
  @@ -853,8 +852,8 @@
       } // createNamespaceBinder():XMLNamespaceBinder
   
       /** Create a datatype validator factory. */
  -    protected DatatypeValidatorFactory createDatatypeValidatorFactory() {
  -        return new DatatypeValidatorFactoryImpl();
  +    protected DTDDVFactory createDatatypeValidatorFactory() {
  +        return DTDDVFactory.getInstance();
       } // createDatatypeValidatorFactory():DatatypeValidatorFactory
       protected ValidationManager createValidationManager(){
           return new ValidationManager();
  
  
  
  1.6       +3 -3      xml-xerces/java/src/org/apache/xerces/parsers/XMLGrammarParser.java
  
  Index: XMLGrammarParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/XMLGrammarParser.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLGrammarParser.java	29 Jan 2002 01:15:17 -0000	1.5
  +++ XMLGrammarParser.java	15 Feb 2002 16:00:30 -0000	1.6
  @@ -58,12 +58,12 @@
   package org.apache.xerces.parsers;
   
   import org.apache.xerces.util.SymbolTable;
  -import org.apache.xerces.impl.dv.dtd.DatatypeValidatorFactory;
  +import org.apache.xerces.impl.dv.DTDDVFactory;
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
   
   /**
  - * @version $Id: XMLGrammarParser.java,v 1.5 2002/01/29 01:15:17 lehors Exp $
  + * @version $Id: XMLGrammarParser.java,v 1.6 2002/02/15 16:00:30 sandygao Exp $
    */
   public abstract class XMLGrammarParser
       extends XMLParser {
  @@ -73,7 +73,7 @@
       //
   
       /** fDatatypeValidatorFactory */
  -    protected DatatypeValidatorFactory fDatatypeValidatorFactory;
  +    protected DTDDVFactory fDatatypeValidatorFactory;
   
       //
       // Constructors
  
  
  

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