You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2001/05/01 16:17:47 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema GeneralAttrCheck.java TraverseSchema.java SchemaSymbols.java

neilg       01/05/01 07:17:46

  Modified:    java/src/org/apache/xerces/validators/schema
                        TraverseSchema.java SchemaSymbols.java
  Added:       java/src/org/apache/xerces/validators/schema
                        GeneralAttrCheck.java
  Log:
  patch from Sandy Gao to implement validation of attributes of schema information items.
  
  Revision  Changes    Path
  1.136     +145 -2    xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java
  
  Index: TraverseSchema.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java,v
  retrieving revision 1.135
  retrieving revision 1.136
  diff -u -r1.135 -r1.136
  --- TraverseSchema.java	2001/05/01 13:56:10	1.135
  +++ TraverseSchema.java	2001/05/01 14:17:44	1.136
  @@ -127,7 +127,7 @@
    *  
    * @see org.apache.xerces.validators.common.Grammar
    *
  - * @version $Id: TraverseSchema.java,v 1.135 2001/05/01 13:56:10 neilg Exp $
  + * @version $Id: TraverseSchema.java,v 1.136 2001/05/01 14:17:44 neilg Exp $
    */
   public class TraverseSchema implements 
                               NamespacesScope.NamespacesHandler{
  @@ -142,7 +142,7 @@
           { SchemaSymbols.URI_SCHEMAFORSCHEMA, SchemaSymbols.ELT_KEY }, 
           { SchemaSymbols.URI_SCHEMAFORSCHEMA, SchemaSymbols.ELT_KEYREF },
       };
  -    private static final String redefIdentifier = "#redefined";
  +    private static final String redefIdentifier = "_redefined";
   
       //debuggin
       private static final boolean DEBUGGING = false;
  @@ -216,6 +216,9 @@
       
       private Hashtable fIdentityConstraints = new Hashtable();
       
  +    // General Attribute Checking
  +    private GeneralAttrCheck fGeneralAttrCheck = null;
  +
      // REVISIT: maybe need to be moved into SchemaGrammar class
       public class ComplexTypeInfo {
           public String typeName;
  @@ -324,11 +327,18 @@
           fDatatypeRegistry = (DatatypeValidatorFactoryImpl) fGrammarResolver.getDatatypeRegistry();
           fDatatypeRegistry.expandRegistryToFullSchemaSet();//Expand to registry type to contain all primitive datatype
   
  +        // General Attribute Checking
  +        fGeneralAttrCheck = new GeneralAttrCheck(fErrorReporter);
  +
           if (root == null) { 
               // REVISIT: Anything to do?
               return;
           }
   
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_GLOBAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(root, scope);
  +
           //Make sure namespace binding is defaulted
           String rootPrefix = root.getPrefix();
           if( rootPrefix == null || rootPrefix.length() == 0 ){
  @@ -502,6 +512,9 @@
               }
           }
   
  +        // General Attribute Checking
  +        fGeneralAttrCheck = null;
  +
       } // traverseSchema(Element)
   
       private void checkTopLevelDuplicateNames(Element root) {
  @@ -624,6 +637,10 @@
   
       private void traverseInclude(Element includeDecl) throws Exception {
   
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_GLOBAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(includeDecl, scope);
  +
           Attr locationAttr = includeDecl.getAttributeNode(SchemaSymbols.ATT_SCHEMALOCATION);
   	    if (locationAttr == null) {
               // REVISIT: Localize
  @@ -719,6 +736,10 @@
       }
   
       private void traverseIncludedSchemaHeader(Element root) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_GLOBAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(root, scope);
  +
           // Retrived the Namespace mapping from the schema element.
           NamedNodeMap schemaEltAttrs = root.getAttributes();
           int i = 0;
  @@ -775,6 +796,10 @@
       } // traverseIncludedSchemaHeader 
   
       private void traverseIncludedSchema(Element root) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_GLOBAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(root, scope);
  +
           checkTopLevelDuplicateNames(root);
   
           //extract all top-level attribute, attributeGroup, and group Decls and put them in the 3 hasn table in the SchemaGrammar.
  @@ -836,6 +861,10 @@
       // that the other schema's info has already been saved, putting the info it finds into the
       // SchemaInfoList element that is passed in.  
       private void openRedefinedSchema(Element redefineDecl, SchemaInfo store) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_GLOBAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(redefineDecl, scope);
  +
           Attr locationAttr = redefineDecl.getAttributeNode(SchemaSymbols.ATT_SCHEMALOCATION);
   	    if (locationAttr == null) {
               // REVISIT: Localize
  @@ -1306,6 +1335,10 @@
       } // validateRedefineNameChange
   
       private void traverseImport(Element importDecl)  throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_GLOBAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(importDecl, scope);
  +
           String location = importDecl.getAttribute(SchemaSymbols.ATT_SCHEMALOCATION);
           // expand it before passing it to the parser
           InputSource source = null;
  @@ -1386,6 +1419,10 @@
       */
       private void traverseAnnotationDecl(Element annotationDecl) throws Exception {
   
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(annotationDecl, scope);
  +
           for(Element child = XUtil.getFirstChildElement(annotationDecl); child != null;
                    child = XUtil.getNextSiblingElement(child)) {
               String name = child.getLocalName();
  @@ -1394,6 +1431,9 @@
                   // REVISIT: Localize
                   reportGenericSchemaError("an <annotation> can only contain <appinfo> and <documentation> elements");
               }
  +
  +            // General Attribute Checking
  +            attrValues = fGeneralAttrCheck.checkAttributes(child, scope);
           }
       }
   
  @@ -1497,6 +1537,12 @@
        */
       private int traverseSimpleTypeDecl( Element simpleTypeDecl ) throws Exception {
                   
  +        // General Attribute Checking
  +        int scope = isTopLevel(simpleTypeDecl)?
  +                    GeneralAttrCheck.ELE_CONTEXT_GLOBAL:
  +                    GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(simpleTypeDecl, scope);
  +
           String nameProperty          =  simpleTypeDecl.getAttribute( SchemaSymbols.ATT_NAME );
           String qualifiedName = nameProperty;
           if (fTargetNSURIString.length () != 0) {
  @@ -1538,6 +1584,11 @@
           if (content == null) {
               return (-1);
           }
  +
  +        // General Attribute Checking
  +        scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable contentAttrs = fGeneralAttrCheck.checkAttributes(content, scope);
  +
           //use content.getLocalName for the cases there "xsd:" is a prefix, ei. "xsd:list"
           String varietyProperty = content.getLocalName();
           String baseTypeQNameProperty = null;
  @@ -1686,6 +1737,8 @@
               String facet;
               while (content != null) { 
                   if (content.getNodeType() == Node.ELEMENT_NODE) {
  +                        // General Attribute Checking
  +                        contentAttrs = fGeneralAttrCheck.checkAttributes(content, scope);
                           numFacets++;
                           facet =content.getLocalName(); 
                           if (facet.equals(SchemaSymbols.ELT_ENUMERATION)) {
  @@ -1822,6 +1875,10 @@
       * </any>
       */
       private int traverseAny(Element child) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(child, scope);
  +
           Element annotation = checkContent( child, XUtil.getFirstChildElement(child), true );
           if(annotation != null ) {
               // REVISIT: Localize
  @@ -1932,6 +1989,10 @@
       * </anyAttribute>
       */
       private XMLAttributeDecl traverseAnyAttribute(Element anyAttributeDecl) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(anyAttributeDecl, scope);
  +
           Element annotation = checkContent( anyAttributeDecl, XUtil.getFirstChildElement(anyAttributeDecl), true );
           if(annotation != null ) {
               // REVISIT: Localize
  @@ -2133,6 +2194,12 @@
       
       private int traverseComplexTypeDecl( Element complexTypeDecl ) throws Exception { 
           
  +        // General Attribute Checking
  +        int scope = isTopLevel(complexTypeDecl)?
  +                    GeneralAttrCheck.ELE_CONTEXT_GLOBAL:
  +                    GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(complexTypeDecl, scope);
  +
           // ------------------------------------------------------------------
           // Get the attributes of the type
           // ------------------------------------------------------------------
  @@ -2332,6 +2399,10 @@
                  throws Exception {
   
           
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(simpleContentDecl, scope);
  +
           String typeName = fStringPool.toString(typeNameIndex);
   
           // -----------------------------------------------------------------------
  @@ -2353,6 +2424,9 @@
             throw new ComplexTypeRecoverableError();
           }
   
  +        // General Attribute Checking
  +        attrValues = fGeneralAttrCheck.checkAttributes(simpleContent, scope);
  +
           // -----------------------------------------------------------------------
           // The content should be either "restriction" or "extension"
           // -----------------------------------------------------------------------
  @@ -2458,6 +2532,10 @@
               Vector enumData            = new Vector();
               Element child;
   
  +             // General Attribute Checking
  +            scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +            Hashtable contentAttrs;
  +
               //REVISIT: there is a better way to do this, 
               for (child = content;
                    child != null && (child.getLocalName().equals(SchemaSymbols.ELT_MINEXCLUSIVE) ||
  @@ -2478,6 +2556,8 @@
               {
                   if ( child.getNodeType() == Node.ELEMENT_NODE ) {
                       Element facetElt = (Element) child;
  +                    // General Attribute Checking
  +                    contentAttrs = fGeneralAttrCheck.checkAttributes(facetElt, scope);
                       numFacets++;
                       if (facetElt.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION)) {
                           numEnumerationLiterals++;
  @@ -2621,6 +2701,10 @@
                  Element complexContentDecl, ComplexTypeInfo typeInfo, 
                  boolean mixedOnComplexTypeDecl) throws Exception { 
   
  +         // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(complexContentDecl, scope);
  +
           String typeName = fStringPool.toString(typeNameIndex);
   
           // -----------------------------------------------------------------------
  @@ -3454,6 +3538,12 @@
        */
       private int traverseAttributeDecl( Element attrDecl, ComplexTypeInfo typeInfo, boolean referredTo ) throws Exception {
   
  +        // General Attribute Checking
  +        int scope = isTopLevel(attrDecl)?
  +                    GeneralAttrCheck.ELE_CONTEXT_GLOBAL:
  +                    GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(attrDecl, scope);
  +
           ////// Get declared fields of the attribute
           String defaultStr   = attrDecl.getAttribute(SchemaSymbols.ATT_DEFAULT);
           String fixedStr     = attrDecl.getAttribute(SchemaSymbols.ATT_FIXED);
  @@ -3878,6 +3968,12 @@
       * 
       */
       private int traverseAttributeGroupDecl( Element attrGrpDecl, ComplexTypeInfo typeInfo, Vector anyAttDecls ) throws Exception {
  +        // General Attribute Checking
  +        int scope = isTopLevel(attrGrpDecl)?
  +                    GeneralAttrCheck.ELE_CONTEXT_GLOBAL:
  +                    GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(attrGrpDecl, scope);
  +
           // attributeGroup name
           String attGrpNameStr = attrGrpDecl.getAttribute(SchemaSymbols.ATT_NAME);
           int attGrpName = fStringPool.addSymbol(attGrpNameStr);
  @@ -4110,6 +4206,12 @@
        */
       private QName traverseElementDecl(Element elementDecl) throws Exception {
   
  +        // General Attribute Checking
  +        int scope = isTopLevel(elementDecl)?
  +                    GeneralAttrCheck.ELE_CONTEXT_GLOBAL:
  +                    GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(elementDecl, scope);
  +
           int contentSpecType      = -1;
           int contentSpecNodeIndex = -1;
           int typeNameIndex = -1;
  @@ -4722,6 +4824,10 @@
       private void traverseUnique(Element uelem, XMLElementDecl edecl) 
           throws Exception {
   
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(uelem, scope);
  +
           // create identity constraint
           String uname = uelem.getAttribute(SchemaSymbols.ATT_NAME);
           if (DEBUG_IDENTITY_CONSTRAINTS) {
  @@ -4741,6 +4847,10 @@
       private void traverseKey(Element kelem, XMLElementDecl edecl)
           throws Exception {
   
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(kelem, scope);
  +
           // create identity constraint
           String kname = kelem.getAttribute(SchemaSymbols.ATT_NAME);
           if (DEBUG_IDENTITY_CONSTRAINTS) {
  @@ -4760,6 +4870,10 @@
       private void traverseKeyRef(Element krelem, XMLElementDecl edecl) 
           throws Exception {
   
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(krelem, scope);
  +
           // create identity constraint
           String krname = krelem.getAttribute(SchemaSymbols.ATT_NAME);
           String kname = krelem.getAttribute(SchemaSymbols.ATT_REFER);
  @@ -4793,9 +4907,16 @@
       private void traverseIdentityConstraint(IdentityConstraint ic, 
                                               Element icElem) throws Exception {
           
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(icelem, scope);
  +
           // check for <annotation> and get selector
           Element sElem = XUtil.getFirstChildElement(icElem);
           sElem = checkContent( icElem, sElem, false);
  +        // General Attribute Checking
  +        attrValues = fGeneralAttrCheck.checkAttributes(selem, scope);
  +
           if(!sElem.getLocalName().equals(SchemaSymbols.ELT_SELECTOR)) {
               // REVISIT: localize
               reportGenericSchemaError("The content of an identity constraint must match (annotation?, selector, field+)");
  @@ -4830,6 +4951,9 @@
           Element fElem = XUtil.getNextSiblingElement(sElem);
   
           while (fElem != null) {
  +            // General Attribute Checking
  +            attrValues = fGeneralAttrCheck.checkAttributes(felem, scope);
  +
               if(!fElem.getLocalName().equals(SchemaSymbols.ELT_FIELD))
                   // REVISIT: localize
                   reportGenericSchemaError("The content of an identity constraint must match (annotation?, selector, field+)");
  @@ -5349,6 +5473,10 @@
        * @exception Exception
        */
       private String traverseNotationDecl( Element notation ) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(notation, scope);
  +
           String name = notation.getAttribute(SchemaSymbols.ATT_NAME);
           String qualifiedName =name;
           if (fTargetNSURIString.length () != 0) {
  @@ -5448,6 +5576,12 @@
        */
       private int traverseGroupDecl( Element groupDecl ) throws Exception {
   
  +        // General Attribute Checking
  +        int scope = isTopLevel(groupDecl)?
  +                    GeneralAttrCheck.ELE_CONTEXT_GLOBAL:
  +                    GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(groupDecl, scope);
  +
           String groupName = groupDecl.getAttribute(SchemaSymbols.ATT_NAME);
           String ref = groupDecl.getAttribute(SchemaSymbols.ATT_REF);
   		Element child = checkContent( groupDecl, XUtil.getFirstChildElement(groupDecl), true );
  @@ -5608,6 +5742,9 @@
       * 
       **/
       int traverseSequence (Element sequenceDecl) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(sequenceDecl, scope);
               
           Element child = checkContent(sequenceDecl, XUtil.getFirstChildElement(sequenceDecl), true);
   
  @@ -5696,6 +5833,9 @@
       * 
       **/
       int traverseChoice (Element choiceDecl) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(choiceDecl, scope);
               
           // REVISIT: traverseChoice, traverseSequence can be combined
           Element child = checkContent(choiceDecl, XUtil.getFirstChildElement(choiceDecl), true);
  @@ -5787,6 +5927,9 @@
       **/
   
       int traverseAll( Element allDecl) throws Exception {
  +        // General Attribute Checking
  +        int scope = GeneralAttrCheck.ELE_CONTEXT_LOCAL;
  +        Hashtable attrValues = fGeneralAttrCheck.checkAttributes(allDecl, scope);
   
           Element child = checkContent(allDecl, XUtil.getFirstChildElement(allDecl), true);
   		if (child == null) return -2;
  
  
  
  1.19      +7 -0      xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaSymbols.java
  
  Index: SchemaSymbols.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaSymbols.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SchemaSymbols.java	2001/04/21 20:10:04	1.18
  +++ SchemaSymbols.java	2001/05/01 14:17:45	1.19
  @@ -136,6 +136,7 @@
       public static final String ATT_FINALDEFAULT =  "finalDefault";
       public static final String ATT_FIXED =  "fixed";
       public static final String ATT_FORM =  "form";
  +    public static final String ATT_ID =  "id";
       public static final String ATT_MAXOCCURS =  "maxOccurs";
       public static final String ATT_MINOCCURS =  "minOccurs";
       public static final String ATT_NAME =  "name";
  @@ -146,6 +147,7 @@
       public static final String ATT_REF =  "ref";
       public static final String ATT_REFER =  "refer";
       public static final String ATT_SCHEMALOCATION =  "schemaLocation";
  +    public static final String ATT_SOURCE =  "source";
       public static final String ATT_SYSTEM =  "system";
       public static final String ATT_PUBLIC =  "public";
       public static final String ATT_TARGETNAMESPACE =  "targetNamespace";
  @@ -153,6 +155,7 @@
       public static final String ATT_USE =  "use";
       public static final String ATT_VALUE = "value";
       public static final String ATT_MIXED = "mixed";
  +    public static final String ATT_VERSION = "version";
       public static final String ATT_XPATH = "xpath";
       public static final String ATT_PRESERVE = "preserve";
       public static final String ATT_REPLACE = "replace";
  @@ -160,6 +163,7 @@
       public static final String ATTVAL_TWOPOUNDANY =  "##any";
       public static final String ATTVAL_TWOPOUNDLOCAL =  "##local";
       public static final String ATTVAL_TWOPOUNDOTHER =  "##other";
  +    public static final String ATTVAL_TWOPOUNDTARGETNS =  "##targetNamespace";
       public static final String ATTVAL_POUNDALL =  "#all";
       public static final String ATTVAL_BOOLEAN =  "boolean";
       public static final String ATTVAL_DEFAULT =  "default";
  @@ -181,12 +185,15 @@
       public static final String ATTVAL_REQUIRED =  "required";
       public static final String ATTVAL_RESTRICTION =  "restriction";
       public static final String ATTVAL_SKIP =  "skip";
  +    public static final String ATTVAL_STRICT =  "strict";
       public static final String ATTVAL_STRING =  "string";
       public static final String ATTVAL_TEXTONLY =  "textOnly";
       public static final String ATTVAL_TIMEDURATION =  "timeDuration";
       public static final String ATTVAL_TRUE =  "true";
  +    public static final String ATTVAL_UNBOUNDED =  "unbounded";
       public static final String ATTVAL_UNQUALIFIED =  "unqualified";
       public static final String ATTVAL_ANYURI =  "anyURI";
  +    public static final String ATTVAL_TOKEN =  "token";
       public static final String ATTVAL_SUBSTITUTIONGROUP = "substitutionGroup";
       public static final String ATTVAL_SUBSTITUTION = "substitution";
   
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/validators/schema/GeneralAttrCheck.java
  
  Index: GeneralAttrCheck.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000,2001 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) 1999, 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.validators.schema;
  
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.xerces.validators.schema.SchemaSymbols;
  import org.apache.xerces.validators.datatype.*;
  import org.apache.xerces.framework.XMLErrorReporter;
  import org.apache.xerces.validators.common.XMLAttributeDecl;
  /**
   * Title:
   * Description:
   * Copyright:    Copyright (c) 2001
   * Company:
   * @author
   * @version 1.0
   */
  
  public class GeneralAttrCheck {
  
      // used to specify in which context the element appears: global or local
      public static int ELE_CONTEXT_GLOBAL    = 0;
      public static int ELE_CONTEXT_LOCAL     = 1;
  
      // used to specify whether the attribute is optional,
      // and whether it has a default value
      public static int ATT_REQUIRED          = 0;
      public static int ATT_OPT_DFLT          = 1;
      public static int ATT_OPT_NODFLT        = 2;
  
      // the prefix to distinguish gloval vs. local; name vs. ref
      protected static String PRE_GLOBAL      = "G_";
      protected static String PRE_LOC_NAME    = "LN_";
      protected static String PRE_LOC_REF     = "LR_";
  
      // used to store the map from element name to attribute list
      protected static Hashtable fEleAttrsMap = new Hashtable();
  
      // used to store extra datatype validators
      protected static DatatypeValidator[] fExtraDVs = null;
  
      // used to initialize fEleAttrsMap
      // step 1: all possible data types
      protected static int dtCount             = 0;
  
      protected static final int DT_ANYURI           = dtCount++;
      protected static final int DT_BOOLEAN          = dtCount++;
      protected static final int DT_ID               = dtCount++;
      protected static final int DT_NONNEGINT        = dtCount++;
      protected static final int DT_QNAME            = dtCount++;
      protected static final int DT_STRING           = dtCount++;
      protected static final int DT_TOKEN            = dtCount++;
      protected static final int DT_NCNAME           = dtCount++;
      protected static final int DT_XPATH            = dtCount++;
  
      protected static final int DT_BLOCK            = -1;
      protected static final int DT_BLOCK1           = DT_BLOCK-1;
      protected static final int DT_FINAL            = DT_BLOCK1-1;
      protected static final int DT_FINAL1           = DT_FINAL-1;
      protected static final int DT_FORM             = DT_FINAL1-1;
      protected static final int DT_MAXOCCURS        = DT_FORM-1;
      protected static final int DT_MAXOCCURS1       = DT_MAXOCCURS-1;
      protected static final int DT_MEMBERTYPES      = DT_MAXOCCURS1-1;
      protected static final int DT_MINOCCURS1       = DT_MEMBERTYPES-1;
      protected static final int DT_NAMESPACE        = DT_MINOCCURS1-1;
      protected static final int DT_PROCESSCONTENTS  = DT_NAMESPACE-1;
      protected static final int DT_PUBLIC           = DT_PROCESSCONTENTS-1;
      protected static final int DT_USE              = DT_PUBLIC-1;
      protected static final int DT_WHITESPACE       = DT_USE-1;
  
      static {
          fExtraDVs = new DatatypeValidator[dtCount];
  
          // step 2: all possible attributes for all elements
          int attCount = 0;
          int ATT_ABSTRACT_D          = attCount++;
          int ATT_ATTRIBUTE_FD_D      = attCount++;
          int ATT_BASE_R              = attCount++;
          int ATT_BLOCK_N             = attCount++;
          int ATT_BLOCK1_N            = attCount++;
          int ATT_BLOCK_D_D           = attCount++;
          int ATT_DEFAULT_N           = attCount++;
          int ATT_ELEMENT_FD_D        = attCount++;
          int ATT_FINAL_N             = attCount++;
          int ATT_FINAL1_N            = attCount++;
          int ATT_FINAL_D_D           = attCount++;
          int ATT_FIXED_N             = attCount++;
          int ATT_FIXED_D             = attCount++;
          int ATT_FORM_N              = attCount++;
          int ATT_ID_N                = attCount++;
          int ATT_ITEMTYPE_N          = attCount++;
          int ATT_MAXOCCURS_D         = attCount++;
          int ATT_MAXOCCURS1_D        = attCount++;
          int ATT_MEMBER_T_N          = attCount++;
          int ATT_MINOCCURS_D         = attCount++;
          int ATT_MINOCCURS1_D        = attCount++;
          int ATT_MIXED_D             = attCount++;
          int ATT_MIXED_N             = attCount++;
          int ATT_NAME_R              = attCount++;
          int ATT_NAMESPACE_D         = attCount++;
          int ATT_NAMESPACE_N         = attCount++;
          int ATT_NILLABLE_D          = attCount++;
          int ATT_PROCESS_C_D         = attCount++;
          int ATT_PUBLIC_R            = attCount++;
          int ATT_REF_R               = attCount++;
          int ATT_REFER_R             = attCount++;
          int ATT_SCHEMA_L_R          = attCount++;
          int ATT_SCHEMA_L_N          = attCount++;
          int ATT_SOURCE_N            = attCount++;
          int ATT_SUBSTITUTION_G_N    = attCount++;
          int ATT_SYSTEM_N            = attCount++;
          int ATT_TARGET_N_N          = attCount++;
          int ATT_TYPE_N              = attCount++;
          int ATT_USE_D               = attCount++;
          int ATT_VALUE_NNI_N         = attCount++;
          int ATT_VALUE_STR_N         = attCount++;
          int ATT_VALUE_WS_N          = attCount++;
          int ATT_VERSION_N           = attCount++;
          int ATT_XPATH_R             = attCount++;
  
          // step 3: store all these attributes in an array
          OneAttr[] allAttrs = new OneAttr[attCount];
          allAttrs[ATT_ABSTRACT_D]        =   new OneAttr(SchemaSymbols.ATT_ABSTRACT,
                                                          DT_BOOLEAN,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_FALSE);
          allAttrs[ATT_ATTRIBUTE_FD_D]    =   new OneAttr(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT,
                                                          DT_FORM,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_UNQUALIFIED);
          allAttrs[ATT_BASE_R]            =   new OneAttr(SchemaSymbols.ATT_BASE,
                                                          DT_QNAME,
                                                          ATT_REQUIRED,
                                                          null);
          allAttrs[ATT_BLOCK_N]           =   new OneAttr(SchemaSymbols.ATT_BLOCK,
                                                          DT_BLOCK,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_BLOCK1_N]          =   new OneAttr(SchemaSymbols.ATT_BLOCK,
                                                          DT_BLOCK1,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_BLOCK_D_D]         =   new OneAttr(SchemaSymbols.ATT_BLOCKDEFAULT,
                                                          DT_BLOCK,
                                                          ATT_OPT_DFLT,
                                                          "");
          allAttrs[ATT_DEFAULT_N]         =   new OneAttr(SchemaSymbols.ATT_DEFAULT,
                                                          DT_STRING,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_ELEMENT_FD_D]      =   new OneAttr(SchemaSymbols.ATT_ELEMENTFORMDEFAULT,
                                                          DT_FORM,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_UNQUALIFIED);
          allAttrs[ATT_FINAL_N]           =   new OneAttr(SchemaSymbols.ATT_FINAL,
                                                          DT_FINAL,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_FINAL1_N]          =   new OneAttr(SchemaSymbols.ATT_FINAL,
                                                          DT_FINAL1,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_FINAL_D_D]         =   new OneAttr(SchemaSymbols.ATT_FINALDEFAULT,
                                                          DT_FINAL,
                                                          ATT_OPT_DFLT,
                                                          "");
          allAttrs[ATT_FIXED_N]           =   new OneAttr(SchemaSymbols.ATT_FIXED,
                                                          DT_STRING,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_FIXED_D]           =   new OneAttr(SchemaSymbols.ATT_FIXED,
                                                          DT_BOOLEAN,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_FALSE);
          allAttrs[ATT_FORM_N]            =   new OneAttr(SchemaSymbols.ATT_FORM,
                                                          DT_FORM,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_ID_N]              =   new OneAttr(SchemaSymbols.ATT_ID,
                                                          DT_ID,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_ITEMTYPE_N]        =   new OneAttr(SchemaSymbols.ATT_ITEMTYPE,
                                                          DT_QNAME,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_MAXOCCURS_D]       =   new OneAttr(SchemaSymbols.ATT_MAXOCCURS,
                                                          DT_MAXOCCURS,
                                                          ATT_OPT_DFLT,
                                                          "1");
          allAttrs[ATT_MAXOCCURS1_D]      =   new OneAttr(SchemaSymbols.ATT_MAXOCCURS,
                                                          DT_MAXOCCURS1,
                                                          ATT_OPT_DFLT,
                                                          "1");
          allAttrs[ATT_MEMBER_T_N]        =   new OneAttr(SchemaSymbols.ATT_MEMBERTYPES,
                                                          DT_MEMBERTYPES,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_MINOCCURS_D]       =   new OneAttr(SchemaSymbols.ATT_MINOCCURS,
                                                          DT_NONNEGINT,
                                                          ATT_OPT_DFLT,
                                                          "1");
          allAttrs[ATT_MINOCCURS1_D]      =   new OneAttr(SchemaSymbols.ATT_MINOCCURS,
                                                          DT_MINOCCURS1,
                                                          ATT_OPT_DFLT,
                                                          "1");
          allAttrs[ATT_MIXED_D]           =   new OneAttr(SchemaSymbols.ATT_MIXED,
                                                          DT_BOOLEAN,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_FALSE);
          allAttrs[ATT_MIXED_N]           =   new OneAttr(SchemaSymbols.ATT_MIXED,
                                                          DT_BOOLEAN,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_NAME_R]            =   new OneAttr(SchemaSymbols.ATT_NAME,
                                                          DT_NCNAME,
                                                          ATT_REQUIRED,
                                                          null);
          allAttrs[ATT_NAMESPACE_D]       =   new OneAttr(SchemaSymbols.ATT_NAMESPACE,
                                                          DT_NAMESPACE,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_TWOPOUNDANY);
          allAttrs[ATT_NAMESPACE_N]       =   new OneAttr(SchemaSymbols.ATT_NAMESPACE,
                                                          DT_ANYURI,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_NILLABLE_D]        =   new OneAttr(SchemaSymbols.ATT_NILLABLE,
                                                          DT_BOOLEAN,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_FALSE);
          allAttrs[ATT_PROCESS_C_D]       =   new OneAttr(SchemaSymbols.ATT_PROCESSCONTENTS,
                                                          DT_PROCESSCONTENTS,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_STRICT);
          allAttrs[ATT_PUBLIC_R]          =   new OneAttr(SchemaSymbols.ATT_PUBLIC,
                                                          DT_PUBLIC,
                                                          ATT_REQUIRED,
                                                          null);
          allAttrs[ATT_REF_R]             =   new OneAttr(SchemaSymbols.ATT_REF,
                                                          DT_QNAME,
                                                          ATT_REQUIRED,
                                                          null);
          allAttrs[ATT_REFER_R]           =   new OneAttr(SchemaSymbols.ATT_REFER,
                                                          DT_QNAME,
                                                          ATT_REQUIRED,
                                                          null);
          allAttrs[ATT_SCHEMA_L_R]        =   new OneAttr(SchemaSymbols.ATT_SCHEMALOCATION,
                                                          DT_ANYURI,
                                                          ATT_REQUIRED,
                                                          null);
          allAttrs[ATT_SCHEMA_L_N]        =   new OneAttr(SchemaSymbols.ATT_SCHEMALOCATION,
                                                          DT_ANYURI,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_SOURCE_N]          =   new OneAttr(SchemaSymbols.ATT_SOURCE,
                                                          DT_ANYURI,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_SUBSTITUTION_G_N]  =   new OneAttr(SchemaSymbols.ATT_SUBSTITUTIONGROUP,
                                                          DT_QNAME,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_SYSTEM_N]          =   new OneAttr(SchemaSymbols.ATT_SYSTEM,
                                                          DT_ANYURI,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_TARGET_N_N]        =   new OneAttr(SchemaSymbols.ATT_TARGETNAMESPACE,
                                                          DT_ANYURI,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_TYPE_N]            =   new OneAttr(SchemaSymbols.ATT_TYPE,
                                                          DT_QNAME,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_USE_D]             =   new OneAttr(SchemaSymbols.ATT_USE,
                                                          DT_USE,
                                                          ATT_OPT_DFLT,
                                                          SchemaSymbols.ATTVAL_OPTIONAL);
          allAttrs[ATT_VALUE_NNI_N]       =   new OneAttr(SchemaSymbols.ATT_VALUE,
                                                          DT_NONNEGINT,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_VALUE_STR_N]       =   new OneAttr(SchemaSymbols.ATT_VALUE,
                                                          DT_STRING,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_VALUE_WS_N]        =   new OneAttr(SchemaSymbols.ATT_VALUE,
                                                          DT_WHITESPACE,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_VERSION_N]         =   new OneAttr(SchemaSymbols.ATT_VERSION,
                                                          DT_TOKEN,
                                                          ATT_OPT_NODFLT,
                                                          null);
          allAttrs[ATT_XPATH_R]           =   new OneAttr(SchemaSymbols.ATT_XPATH,
                                                          DT_XPATH,
                                                          ATT_REQUIRED,
                                                          null);
  
          // step 4: for each element, make a list of possible attributes
          Hashtable attrList;
          Object[] attrArray;
          OneElement oneEle;
  
          // for element "attribute" - global
          attrList = new Hashtable();
          // default = string
          attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
          // fixed = string
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          // type = QName
          attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_ATTRIBUTE, oneEle);
  
          // for element "attribute" - local name
          attrList = new Hashtable();
          // default = string
          attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
          // fixed = string
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
          // form = (qualified | unqualified)
          attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          // type = QName
          attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
          // use = (optional | prohibited | required) : optional
          attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ATTRIBUTE, oneEle);
  
          // for element "attribute" - local ref
          attrList = new Hashtable();
          // default = string
          attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
          // fixed = string
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // ref = QName
          attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
          // use = (optional | prohibited | required) : optional
          attrList.put(SchemaSymbols.ATT_USE, allAttrs[ATT_USE_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_REF+SchemaSymbols.ELT_ATTRIBUTE, oneEle);
  
          // for element "element" - global
          attrList = new Hashtable();
          // abstract = boolean : false
          attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]);
          // block = (#all | List of (substitution | extension | restriction | list | union))
          attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
          // default = string
          attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
          // final = (#all | List of (extension | restriction))
          attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]);
          // fixed = string
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          // nillable = boolean : false
          attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]);
          // substitutionGroup = QName
          attrList.put(SchemaSymbols.ATT_SUBSTITUTIONGROUP, allAttrs[ATT_SUBSTITUTION_G_N]);
          // type = QName
          attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_ELEMENT, oneEle);
  
          // for element "element" - local name
          attrList = new Hashtable();
          // block = (#all | List of (substitution | extension | restriction | list | union))
          attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK_N]);
          // default = string
          attrList.put(SchemaSymbols.ATT_DEFAULT, allAttrs[ATT_DEFAULT_N]);
          // fixed = string
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_N]);
          // form = (qualified | unqualified)
          attrList.put(SchemaSymbols.ATT_FORM, allAttrs[ATT_FORM_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = (nonNegativeInteger | unbounded)  : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
          // minOccurs = nonNegativeInteger : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          // nillable = boolean : false
          attrList.put(SchemaSymbols.ATT_NILLABLE, allAttrs[ATT_NILLABLE_D]);
          // type = QName
          attrList.put(SchemaSymbols.ATT_TYPE, allAttrs[ATT_TYPE_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ELEMENT, oneEle);
  
          // for element "element" - local ref
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = (nonNegativeInteger | unbounded)  : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
          // minOccurs = nonNegativeInteger : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
          // ref = QName
          attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_REF+SchemaSymbols.ELT_ELEMENT, oneEle);
  
          // for element "complexType" - global
          attrList = new Hashtable();
          // abstract = boolean : false
          attrList.put(SchemaSymbols.ATT_ABSTRACT, allAttrs[ATT_ABSTRACT_D]);
          // block = (#all | List of (extension | restriction))
          attrList.put(SchemaSymbols.ATT_BLOCK, allAttrs[ATT_BLOCK1_N]);
          // final = (#all | List of (extension | restriction))
          attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // mixed = boolean : false
          attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_COMPLEXTYPE, oneEle);
  
          // for element "complexType" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // mixed = boolean : false
          attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_COMPLEXTYPE, oneEle);
  
          // for element "simpleContent" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_SIMPLECONTENT, oneEle);
  
          // for element "restriction" - local name
          attrList = new Hashtable();
          // base = QName
          attrList.put(SchemaSymbols.ATT_BASE, allAttrs[ATT_BASE_R]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_RESTRICTION, oneEle);
          // for element "extension" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_EXTENSION, oneEle);
  
          // for element "attributeGroup" - local ref
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // ref = QName
          attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_REF+SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle);
  
          // for element "anyAttribute" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )  : ##any
          attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]);
          // processContents = (lax | skip | strict) : strict
          attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ANYATTRIBUTE, oneEle);
  
          // for element "complexContent" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // mixed = boolean
          attrList.put(SchemaSymbols.ATT_MIXED, allAttrs[ATT_MIXED_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_COMPLEXCONTENT, oneEle);
  
          // for element "attributeGroup" - global
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_ATTRIBUTEGROUP, oneEle);
  
          // for element "group" - global
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = (nonNegativeInteger | unbounded)  : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
          // minOccurs = nonNegativeInteger : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_GROUP, oneEle);
  
          // for element "group" - local ref
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = (nonNegativeInteger | unbounded)  : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
          // minOccurs = nonNegativeInteger : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
          // ref = QName
          attrList.put(SchemaSymbols.ATT_REF, allAttrs[ATT_REF_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_REF+SchemaSymbols.ELT_GROUP, oneEle);
  
          // for element "all" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = 1 : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS1_D]);
          // minOccurs = (0 | 1) : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS1_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ALL, oneEle);
  
          // for element "choice" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = (nonNegativeInteger | unbounded)  : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
          // minOccurs = nonNegativeInteger : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_CHOICE, oneEle);
          // for element "sequence" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_SEQUENCE, oneEle);
  
          // for element "any" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // maxOccurs = (nonNegativeInteger | unbounded)  : 1
          attrList.put(SchemaSymbols.ATT_MAXOCCURS, allAttrs[ATT_MAXOCCURS_D]);
          // minOccurs = nonNegativeInteger : 1
          attrList.put(SchemaSymbols.ATT_MINOCCURS, allAttrs[ATT_MINOCCURS_D]);
          // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )  : ##any
          attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_D]);
          // processContents = (lax | skip | strict) : strict
          attrList.put(SchemaSymbols.ATT_PROCESSCONTENTS, allAttrs[ATT_PROCESS_C_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ANY, oneEle);
  
          // for element "unique" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_UNIQUE, oneEle);
          // for element "key" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_KEY, oneEle);
  
          // for element "keyref" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          // refer = QName
          attrList.put(SchemaSymbols.ATT_REFER, allAttrs[ATT_REFER_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_KEYREF, oneEle);
  
          // for element "selector" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // xpath = a subset of XPath expression
          attrList.put(SchemaSymbols.ATT_XPATH, allAttrs[ATT_XPATH_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_SELECTOR, oneEle);
          // for element "field" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_FIELD, oneEle);
  
          // for element "notation" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          // public = A public identifier, per ISO 8879
          attrList.put(SchemaSymbols.ATT_PUBLIC, allAttrs[ATT_PUBLIC_R]);
          // system = anyURI
          attrList.put(SchemaSymbols.ATT_SYSTEM, allAttrs[ATT_SYSTEM_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_NOTATION, oneEle);
  
          // for element "annotation" - global
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_ANNOTATION, oneEle);
          // for element "annotation" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ANNOTATION, oneEle);
  
          // for element "appinfo" - local name
          attrList = new Hashtable();
          // source = anyURI
          attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_APPINFO, oneEle);
  
          // for element "documentation" - local name
          attrList = new Hashtable();
          // source = anyURI
          attrList.put(SchemaSymbols.ATT_SOURCE, allAttrs[ATT_SOURCE_N]);
          // xml:lang = language ???
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_DOCUMENTATION, oneEle);
  
          // for element "simpleType" - global
          attrList = new Hashtable();
          // final = (#all | (list | union | restriction))
          attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // name = NCName
          attrList.put(SchemaSymbols.ATT_NAME, allAttrs[ATT_NAME_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_SIMPLETYPE, oneEle);
  
          // for element "simpleType" - local name
          attrList = new Hashtable();
          // final = (#all | (list | union | restriction))
          attrList.put(SchemaSymbols.ATT_FINAL, allAttrs[ATT_FINAL1_N]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_SIMPLETYPE, oneEle);
  
          // for element "restriction" - local name
          // already registered for complexType
  
          // for element "list" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // itemType = QName
          attrList.put(SchemaSymbols.ATT_ITEMTYPE, allAttrs[ATT_ITEMTYPE_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_LIST, oneEle);
  
          // for element "union" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // memberTypes = List of QName
          attrList.put(SchemaSymbols.ATT_MEMBERTYPES, allAttrs[ATT_MEMBER_T_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_UNION, oneEle);
  
          // for element "schema" - global
          attrList = new Hashtable();
          // attributeFormDefault = (qualified | unqualified) : unqualified
          attrList.put(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT, allAttrs[ATT_ATTRIBUTE_FD_D]);
          // blockDefault = (#all | List of (substitution | extension | restriction | list | union))  : ''
          attrList.put(SchemaSymbols.ATT_BLOCKDEFAULT, allAttrs[ATT_BLOCK_D_D]);
          // elementFormDefault = (qualified | unqualified) : unqualified
          attrList.put(SchemaSymbols.ATT_ELEMENTFORMDEFAULT, allAttrs[ATT_ELEMENT_FD_D]);
          // finalDefault = (#all | List of (extension | restriction))  : ''
          attrList.put(SchemaSymbols.ATT_FINALDEFAULT, allAttrs[ATT_FINAL_D_D]);
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // targetNamespace = anyURI
          attrList.put(SchemaSymbols.ATT_TARGETNAMESPACE, allAttrs[ATT_TARGET_N_N]);
          // version = token
          attrList.put(SchemaSymbols.ATT_VERSION, allAttrs[ATT_VERSION_N]);
          // xml:lang = language ???
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_SCHEMA, oneEle);
  
          // for element "include" - global
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // schemaLocation = anyURI
          attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_R]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_INCLUDE, oneEle);
          // for element "redefine" - global
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_REDEFINE, oneEle);
  
          // for element "import" - global
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // namespace = anyURI
          attrList.put(SchemaSymbols.ATT_NAMESPACE, allAttrs[ATT_NAMESPACE_N]);
          // schemaLocation = anyURI
          attrList.put(SchemaSymbols.ATT_SCHEMALOCATION, allAttrs[ATT_SCHEMA_L_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_GLOBAL+SchemaSymbols.ELT_IMPORT, oneEle);
  
          // for element "length" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // value = nonNegativeInteger
          attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_NNI_N]);
          // fixed = boolean : false
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_LENGTH, oneEle);
          // for element "minLength" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_MINLENGTH, oneEle);
          // for element "maxLength" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_MAXLENGTH, oneEle);
          // for element "totalDigits" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_TOTALDIGITS, oneEle);
          // for element "fractionDigits" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_FRACTIONDIGITS, oneEle);
  
          // for element "pattern" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // value = string
          attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_PATTERN, oneEle);
  
          // for element "enumeration" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // value = anySimpleType ???
          attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_ENUMERATION, oneEle);
  
          // for element "whiteSpace" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // value = preserve | replace | collapse
          attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_WS_N]);
          // fixed = boolean : false
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_WHITESPACE, oneEle);
  
          // for element "maxInclusive" - local name
          attrList = new Hashtable();
          // id = ID
          attrList.put(SchemaSymbols.ATT_ID, allAttrs[ATT_ID_N]);
          // value = anySimpleType ???
          attrList.put(SchemaSymbols.ATT_VALUE, allAttrs[ATT_VALUE_STR_N]);
          // fixed = boolean : false
          attrList.put(SchemaSymbols.ATT_FIXED, allAttrs[ATT_FIXED_D]);
          oneEle = new OneElement (attrList);
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_MAXINCLUSIVE, oneEle);
          // for element "maxExclusive" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_MAXEXCLUSIVE, oneEle);
          // for element "minInclusive" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_MININCLUSIVE, oneEle);
          // for element "minExclusive" - local name
          fEleAttrsMap.put(PRE_LOC_NAME+SchemaSymbols.ELT_MINEXCLUSIVE, oneEle);
  
  
          // step 5: register all datatype validators for new types
          Hashtable facets;
          DatatypeValidator extraDV;
          try {
              // anyURI
              extraDV = new AnyURIDatatypeValidator();
              fExtraDVs[DT_ANYURI] = extraDV;
  
              // boolean
              extraDV = new BooleanDatatypeValidator();
              fExtraDVs[DT_BOOLEAN] = extraDV;
  
              // ID
              extraDV = new IDDatatypeValidator();
              fExtraDVs[DT_ID] = extraDV;
  
              // nonNegtiveInteger
              facets = new Hashtable();
              facets.put(SchemaSymbols.ELT_FRACTIONDIGITS, "0");
              facets.put(SchemaSymbols.ELT_MININCLUSIVE, "0" );
              extraDV = new DecimalDatatypeValidator(null, facets, false);
              fExtraDVs[DT_NONNEGINT] = extraDV;
  
              // QName
              extraDV = new QNameDatatypeValidator();
              fExtraDVs[DT_QNAME] = extraDV;
  
              // string
              extraDV = new StringDatatypeValidator();
              fExtraDVs[DT_STRING] = extraDV;
  
              // token
              facets = new Hashtable();
              facets.put(SchemaSymbols.ELT_WHITESPACE, SchemaSymbols.ATT_COLLAPSE);
              extraDV = new StringDatatypeValidator(null, facets, false);
              fExtraDVs[DT_TOKEN] = extraDV;
  
              // NCName
              facets = new Hashtable();
              facets.put(SchemaSymbols.ELT_PATTERN, "[\\i-[:]][\\c-[:]]*");
              extraDV = new StringDatatypeValidator(fExtraDVs[DT_TOKEN], facets, false);
              fExtraDVs[DT_NCNAME] = extraDV;
  
              // xpath = a subset of XPath expression
              facets = new Hashtable();
              facets.put(SchemaSymbols.ELT_PATTERN, "(\\.//)?(((child::)?((\\i\\c*:)?(\\i\\c*|\\*)))|\\.)(/(((child::)?((\\i\\c*:)?(\\i\\c*|\\*)))|\\.))*(\\|(\\.//)?(((child::)?((\\i\\c*:)?(\\i\\c*|\\*)))|\\.)(/(((child::)?((\\i\\c*:)?(\\i\\c*|\\*)))|\\.))*)*");
              extraDV = new StringDatatypeValidator(fExtraDVs[DT_TOKEN], facets, false);
              fExtraDVs[DT_XPATH] = extraDV;
  
          } catch (InvalidDatatypeFacetException ide) {
              // shouldn't be any problem
          }
      }
  
      // used to store utility reference: error reproter. set via constructor.
      protected XMLErrorReporter fErrorReporter = null;
  
      // constructor. Sets fDVRegistry and fErrorReproter
      public GeneralAttrCheck(XMLErrorReporter er) {
          fErrorReporter = er;
      }
  
      // check whether the specified element conforms to the attributes restriction
      // @param: element    - which element to check
      // @param: eleContext - the context in which the element is
      // @return: Hashtable - list of attributes and values
      public Hashtable checkAttributes(Element element, int eleContext) throws Exception {
          if (element == null)
              return null;
  
          // Get the proper name:
          // G_ for global;
          // LN_ for local + name;
          // LR_ for local + ref;
          String elName = element.getLocalName(), name;
          if (eleContext == ELE_CONTEXT_GLOBAL) {
              name = PRE_GLOBAL + element.getLocalName();
          } else {
              if (element.getAttributeNode(SchemaSymbols.ATT_REF) == null)
                  name = PRE_LOC_NAME + element.getLocalName();
              else
                  name = PRE_LOC_REF + element.getLocalName();
          }
  
          // get desired attribute list of this element
          OneElement oneEle = (OneElement)fEleAttrsMap.get(name);
          if (oneEle == null) {
              reportSchemaError (SchemaMessageProvider.GenericError,
                                 new Object[] {"Element '"+elName+"' cannot appear here"});
              return null;
          }
  
          Hashtable attrValues = new Hashtable();
          Hashtable attrList = oneEle.attrList;
  
          // traverse all attributes
          NamedNodeMap attrs = element.getAttributes();
          Attr sattr = null;
          int i = 0;
          while ((sattr = (Attr)attrs.item(i++)) != null) {
              // skip anything starts with x/X m/M l/L ???
              // simply put their values in the return hashtable
              if (sattr.getName().toLowerCase().startsWith("xml")) {
                  attrValues.put(sattr.getName(), sattr.getValue());
                  continue;
              }
  
              // check whether this attribute is allowed
              String attrName = sattr.getLocalName();
              OneAttr oneAttr = (OneAttr)attrList.get(attrName);
              if (oneAttr == null) {
                  reportSchemaError (SchemaMessageProvider.GenericError,
                                     new Object[] {"Attribute '"+attrName+"' cannot appear in '"+elName+"'"});
                  continue;
              }
  
              // get the attribute valud, and check it against the datatype
              String attrVal = sattr.getValue();
  
              try {
                  // if we validate ID types here, when it's validated again in
                  // TraverseSchema, the validator would think it's already defined.
                  // disable this temprorily. Enable it after modify TraverseSchema.
                  // and URI doesn't validate relative URIs, so disable it too.
                  if (oneAttr.dvIndex >= 0) {
                      if (!(fExtraDVs[oneAttr.dvIndex] instanceof IDDatatypeValidator) &&
                          !(fExtraDVs[oneAttr.dvIndex] instanceof AnyURIDatatypeValidator) &&
                          !(fExtraDVs[oneAttr.dvIndex] instanceof NOTATIONDatatypeValidator)) //???
                          fExtraDVs[oneAttr.dvIndex].validate(attrVal, null);
                      attrValues.put(attrName, attrVal);
                  } else {
                      attrVal = validate(attrName, attrVal, oneAttr.dvIndex);
                      attrValues.put(attrName, attrVal);
                  }
              } catch(InvalidDatatypeValueException ide) {
                  reportSchemaError (SchemaMessageProvider.GenericError,
                                     new Object[] {"Invalid attribute value '"+attrVal+"' for '"+attrName+"' in '"+ elName +"'"});
              }
          }
  
          // traverse all required attributes
          Object[] reqAttrs = oneEle.attrArray;
          for (i = 0; i < reqAttrs.length; i++) {
              OneAttr oneAttr = (OneAttr)reqAttrs[i];
  
              // if the attribute appreared, skip to the next one
              if (element.getAttributeNode(oneAttr.name) != null)
                  continue;
  
              // if the attribute is required, report an error
              if (oneAttr.optdflt == ATT_REQUIRED) {
                  reportSchemaError (SchemaMessageProvider.GenericError,
                                     new Object[] {"Attribute '"+oneAttr.name+"' must appear in '"+elName+"'"});
              }
              // if the attribute is optional with default value, apply it
              else if (oneAttr.optdflt == ATT_OPT_DFLT) {
                  attrValues.put(oneAttr.name, oneAttr.dfltValue);
              }
          }
  
          return attrValues;
      }
  
      private String validate(String attr, String value, int dvIndex) throws InvalidDatatypeValueException {
          Vector unionBase, enum;
          int choice;
  
          if (value == null)
              return null;
  
          switch (dvIndex) {
          case DT_BLOCK:
              // block = (#all | List of (substitution | extension | restriction | list | union))
              choice = 0;
              if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
                  choice = SchemaSymbols.SUBSTITUTION+SchemaSymbols.EXTENSION+
                           SchemaSymbols.RESTRICTION+SchemaSymbols.LIST+
                           SchemaSymbols.UNION;
              } else {
                  StringTokenizer t = new StringTokenizer (value, " ");
                  while (t.hasMoreTokens()) {
                      String token = t.nextToken ();
  
                      if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION) ) {
                          if ((choice & SchemaSymbols.SUBSTITUTION) == 0) {
                              choice |= SchemaSymbols.SUBSTITUTION;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
                          if ( (choice & SchemaSymbols.EXTENSION) == 0 ) {
                                  choice |= SchemaSymbols.EXTENSION;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
                          if ( (choice & SchemaSymbols.RESTRICTION) == 0 ) {
                              choice |= SchemaSymbols.RESTRICTION;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else if ( token.equals (SchemaSymbols.ELT_LIST) ) {
                          if ( (choice & SchemaSymbols.LIST) == 0 ) {
                                  choice |= SchemaSymbols.LIST;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else if ( token.equals (SchemaSymbols.ELT_UNION) ) {
                          if ( (choice & SchemaSymbols.RESTRICTION) == 0 ) {
                              choice |= SchemaSymbols.RESTRICTION;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else {
                          throw new InvalidDatatypeValueException();
                      }
                  }
              }
              value = Integer.toString(choice);
              break;
          case DT_BLOCK1:
          case DT_FINAL:
              // block = (#all | List of (extension | restriction))
              // final = (#all | List of (extension | restriction))
              choice = 0;
              if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
                  choice = SchemaSymbols.EXTENSION+SchemaSymbols.RESTRICTION;
              } else {
                  StringTokenizer t = new StringTokenizer (value, " ");
                  while (t.hasMoreTokens()) {
                      String token = t.nextToken ();
  
                      if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
                          if ( (choice & SchemaSymbols.EXTENSION) == 0 ) {
                                  choice |= SchemaSymbols.EXTENSION;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
                          if ( (choice & SchemaSymbols.RESTRICTION) == 0 ) {
                              choice |= SchemaSymbols.RESTRICTION;
                          } else {
                              throw new InvalidDatatypeValueException();
                          }
                      } else {
                          throw new InvalidDatatypeValueException();
                      }
                  }
              }
              value = Integer.toString(choice);
              break;
          case DT_FINAL1:
              // final = (#all | (list | union | restriction))
              choice = 0;
              if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
                  choice = SchemaSymbols.RESTRICTION+SchemaSymbols.LIST+
                           SchemaSymbols.UNION;
              } else if (value.equals (SchemaSymbols.ELT_LIST)) {
                  choice = SchemaSymbols.LIST;
              } else if (value.equals (SchemaSymbols.ELT_UNION)) {
                  choice = SchemaSymbols.UNION;
              } else if (value.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
                  choice = SchemaSymbols.RESTRICTION;
              } else {
                  throw new InvalidDatatypeValueException();
              }
              value = Integer.toString(choice);
              break;
          case DT_FORM:
              // form = (qualified | unqualified)
              if (!value.equals (SchemaSymbols.ATTVAL_QUALIFIED) &&
                  !value.equals (SchemaSymbols.ATTVAL_UNQUALIFIED)) {
                  throw new InvalidDatatypeValueException();
              }
              break;
          case DT_MAXOCCURS:
              // maxOccurs = (nonNegativeInteger | unbounded)
              if (!value.equals("unbounded")) {
                  fExtraDVs[DT_NONNEGINT].validate(value, null);
              }
              break;
          case DT_MAXOCCURS1:
              // maxOccurs = 1
              if (!value.equals("1"))
                  throw new InvalidDatatypeValueException();
              break;
          case DT_MEMBERTYPES:
              // memberTypes = List of QName
              {
                  StringTokenizer t = new StringTokenizer (value, " ");
                  while (t.hasMoreTokens()) {
                      String token = t.nextToken ();
                      fExtraDVs[DT_QNAME].validate(token, null);
                  }
              }
              break;
          case DT_MINOCCURS1:
              // minOccurs = (0 | 1)
              if (!value.equals("0") && !value.equals("1"))
                  throw new InvalidDatatypeValueException();
              break;
          case DT_NAMESPACE:
              // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
              if (!value.equals(SchemaSymbols.ATTVAL_TWOPOUNDANY) &&
                  !value.equals(SchemaSymbols.ATTVAL_TWOPOUNDOTHER)) {
                  StringTokenizer t = new StringTokenizer (value, " ");
                  while (t.hasMoreTokens()) {
                      String token = t.nextToken ();
                      if (!token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS) &&
                          !token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) {
                          fExtraDVs[DT_ANYURI].validate(token, null);
                      }
                  }
              }
              break;
          case DT_PROCESSCONTENTS:
              // processContents = (lax | skip | strict)
              if (!value.equals (SchemaSymbols.ATTVAL_SKIP) &&
                  !value.equals (SchemaSymbols.ATTVAL_LAX) &&
                  !value.equals (SchemaSymbols.ATTVAL_STRICT)) {
                  throw new InvalidDatatypeValueException();
              }
              break;
          case DT_PUBLIC:
              // public = A public identifier, per ISO 8879 ???
              fExtraDVs[DT_TOKEN].validate(value, null);
              break;
          case DT_USE:
              // use = (optional | prohibited | required)
              if (!value.equals (SchemaSymbols.ATTVAL_OPTIONAL) &&
                  !value.equals (SchemaSymbols.ATTVAL_PROHIBITED) &&
                  !value.equals (SchemaSymbols.ATTVAL_REQUIRED)) {
                  throw new InvalidDatatypeValueException();
              }
              break;
          case DT_WHITESPACE:
              // value = preserve | replace | collapse
              if (!value.equals (SchemaSymbols.ATT_PRESERVE) &&
                  !value.equals (SchemaSymbols.ATT_REPLACE) &&
                  !value.equals (SchemaSymbols.ATT_COLLAPSE)) {
                  throw new InvalidDatatypeValueException();
              }
              break;
          }
  
          return value;
      }
  
      // report an error. copied from TraverseSchema
      private void reportSchemaError(int major, Object args[]) throws Exception {
          if (fErrorReporter == null) {
              System.out.println("__TraverseSchemaError__ : " + SchemaMessageProvider.fgMessageKeys[major]);
              for (int i=0; i< args.length ; i++) {
                  System.out.println((String)args[i]);
              }
          }
          else {
              fErrorReporter.reportError(fErrorReporter.getLocator(),
                                         SchemaMessageProvider.SCHEMA_DOMAIN,
                                         major,
                                         SchemaMessageProvider.MSG_NONE,
                                         args,
                                         XMLErrorReporter.ERRORTYPE_RECOVERABLE_ERROR);
          }
      }
  }
  
  class OneAttr {
      // name of the attribute
      public String name;
      // index of the datatype validator
      public int dvIndex;
      // whether it's optional, and has default value
      public int optdflt;
      // the default value of this attribute
      public String dfltValue;
  
      public OneAttr(String name, int dvIndex, int optdflt, String dfltValue) {
          this.name = name;
          this.dvIndex = dvIndex;
          this.optdflt = optdflt;
          this.dfltValue = dfltValue;
      }
  }
  
  class OneElement {
      // the list of attributes that can appear in one element
      public Hashtable attrList;
      // the array of attributes that can appear in one element
      public Object[] attrArray;
  
      public OneElement (Hashtable attrList) {
          this.attrList = attrList;
          this.attrArray = attrList.values().toArray();
      }
  }
  
  
  

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