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 2001/08/28 21:57:46 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/v2 SchemaSymbols.java XSAttributeChecker.java XSDElementTraverser.java XSDHandler.java XSElementDecl.java

sandygao    01/08/28 12:57:46

  Modified:    java/src/org/apache/xerces/impl/v2 SchemaSymbols.java
                        XSAttributeChecker.java XSDElementTraverser.java
                        XSDHandler.java XSElementDecl.java
  Log:
  1. Changed XMLManipulator to DOMUtil
  2. Modified attribute checker to return whether a value is specified or from default
  3. Implemented ElementTraverser: global element (doesn't compile yet).
  
  Revision  Changes    Path
  1.3       +15 -1     xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaSymbols.java
  
  Index: SchemaSymbols.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/SchemaSymbols.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SchemaSymbols.java	2001/08/27 22:54:33	1.2
  +++ SchemaSymbols.java	2001/08/28 19:57:46	1.3
  @@ -62,7 +62,7 @@
    * Collection of symbols used to parse a Schema Grammar.
    *
    * @author jeffrey rodriguez
  - * @version $Id: SchemaSymbols.java,v 1.2 2001/08/27 22:54:33 sandygao Exp $
  + * @version $Id: SchemaSymbols.java,v 1.3 2001/08/28 19:57:46 sandygao Exp $
    */
   public final  class SchemaSymbols {
       // schema namespaces
  @@ -163,6 +163,8 @@
       public static final String ATTVAL_POUNDALL          = "#all";
       public static final String ATTVAL_FALSE_0           = "0";
       public static final String ATTVAL_TRUE_1            = "1";
  +    public static final String ATTVAL_ANYSIMPLETYPE     = "anySimpleType";
  +    public static final String ATTVAL_ANYTYPE           = "anyType";
       public static final String ATTVAL_ANYURI            = "anyURI";
       public static final String ATTVAL_BOOLEAN           = "boolean";
       public static final String ATTVAL_COLLAPSE          = "collapse";
  @@ -192,6 +194,14 @@
       public static final String ATTVAL_UNION             = "union";
       public static final String ATTVAL_UNQUALIFIED       = "unqualified";
   
  +    // from default value
  +    public static final int FROM_DEFAULT  = 0x4000;
  +    public static final int REAL_VALUE    = 0x3fff;
  +
  +    // boolean true/false
  +    public static final int BOOLEAN_FALSE = 0;
  +    public static final int BOOLEAN_TRUE  = 1;
  +
       // block/final values
       public static final int EMPTY_SET    = 0;
       public static final int EXTENSION    = 1;
  @@ -200,6 +210,10 @@
       public static final int LIST         = 8;
       public static final int ENUMERATION  = 16;
       public static final int SUBSTITUTION = 32;
  +
  +    // form qualified/unqualified
  +    public static final int FORM_UNQUALIFIED = 0;
  +    public static final int FORM_QUALIFIED   = 1;
   
       // any: processContents
       public static final int ANY_STRICT = 0;
  
  
  
  1.7       +110 -122  xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeChecker.java
  
  Index: XSAttributeChecker.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSAttributeChecker.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSAttributeChecker.java	2001/08/28 18:50:48	1.6
  +++ XSAttributeChecker.java	2001/08/28 19:57:46	1.7
  @@ -69,48 +69,70 @@
   */
   
   /**
  - * @version $Id: XSAttributeChecker.java,v 1.6 2001/08/28 18:50:48 neilg Exp $
  +<<<<<<< XSAttributeChecker.java
  + * Class <code>XSAttributeCheck</code> is used to check the validity of attributes
  + * appearing in the schema document. It
  + * - reports an error for invalid element (invalid namespace, invalid name)
  + * - reports an error for invalid attribute (invalid namespace, invalid name)
  + * - reports an error for invalid attribute value
  + * - return compiled values for attriute values
  + * - provide default value for missing optional attributes
  + * - provide default value for incorrect attribute values
  + *
  + * But it's the caller's responsibility to check whether a required attribute
  + * is present.
  + *
  + * Things need revisiting:
  + * - Checking on non-schema namespace attributes
  + * - Do we need to check whether an element is a child of appinfo or documentation?
  + * - We need NamespaceScope to generate QName
  + * - Do we need to update NamespaceScope and ErrorReporter when reset()?
  + * - Should have the datatype validators return compiled value
  + * - Should return QName instead of String for QName type values
  + * - Should return compiled form for wildcard namespace
  + *
  + * @version $Id: XSAttributeChecker.java,v 1.7 2001/08/28 19:57:46 sandygao Exp $
  +=======
  + * @version $Id: XSAttributeChecker.java,v 1.7 2001/08/28 19:57:46 sandygao Exp $
  +>>>>>>> 1.6
    */
   
   public class XSAttributeChecker {
   
  -    // store the value of an attribute in a compiled form
  -    public class AttrVal {
  -        // value
  -        Object val;
  -        // if this attribute is not specified, and the value is provided
  -        // by the default value, then fromDefault == true
  -        boolean fromDefault;
  -        // constructor
  -        protected AttrVal(Object val, boolean fromDefault) {
  -            this.val = val;
  -            this.fromDefault = fromDefault;
  -        }
  -    }
  -
  -    private static Boolean FORM_QUALIFIED     = Boolean.TRUE;
  -    private static Boolean FORM_UNQUALIFIED   = Boolean.FALSE;
  -    private static Integer INT_ZERO           = new Integer(0);
  -    private static Integer INT_EMPTY_SET      = INT_ZERO;
  -    private static Integer INT_ANY_STRICT     = INT_ZERO;
  -    private static Integer INT_USE_OPTIONAL   = INT_ZERO;
  -    private static Integer INT_WS_PRESERVE    = INT_ZERO;
  -    private static Integer INT_ONE            = new Integer(1);
  -    private static Integer INT_ANY_LAX        = INT_ONE;
  -    private static Integer INT_USE_REQUIRED   = INT_ONE;
  -    private static Integer INT_WS_REPLACE     = INT_ONE;
  -    private static Integer INT_TWO            = new Integer(2);
  -    private static Integer INT_ANY_SKIP       = INT_TWO;
  -    private static Integer INT_USE_PROHIBITED = INT_TWO;
  -    private static Integer INT_WS_COLLAPSE    = INT_TWO;
  -
  -    private static Integer INT_UNBOUNDED = new Integer(SchemaSymbols.OCCURRENCE_UNBOUNDED);
  -
  -    // 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;
  +    // constants to return
  +    private static Integer[] INTD_CONSTANTS   = {new Integer(0 | SchemaSymbols.FROM_DEFAULT),
  +                                                 new Integer(1 | SchemaSymbols.FROM_DEFAULT),
  +                                                 new Integer(2 | SchemaSymbols.FROM_DEFAULT)};
  +    private static Integer INTD_ONE           = INTD_CONSTANTS[1];
  +    private static Integer INTD_TRUE          = INTD_CONSTANTS[SchemaSymbols.BOOLEAN_TRUE];
  +    private static Integer INTD_FALSE         = INTD_CONSTANTS[SchemaSymbols.BOOLEAN_FALSE];
  +    private static Integer INTD_QUALIFIED     = INTD_CONSTANTS[SchemaSymbols.FORM_QUALIFIED];
  +    private static Integer INTD_UNQUALIFIED   = INTD_CONSTANTS[SchemaSymbols.FORM_UNQUALIFIED];
  +    private static Integer INTD_EMPTY_SET     = INTD_CONSTANTS[SchemaSymbols.EMPTY_SET];
  +    private static Integer INTD_ANY_STRICT    = INTD_CONSTANTS[SchemaSymbols.ANY_STRICT];
  +    private static Integer INTD_USE_OPTIONAL  = INTD_CONSTANTS[SchemaSymbols.USE_OPTIONAL];
  +
  +    // integer values
  +    private static Integer[] INT_CONSTANTS    = {new Integer(0),
  +                                                 new Integer(1),
  +                                                 new Integer(2)};
  +    private static Integer INT_ZERO           = INT_CONSTANTS[1];
  +    private static Integer INT_ONE            = INT_CONSTANTS[1];
  +    private static Integer INT_TRUE           = INT_CONSTANTS[SchemaSymbols.BOOLEAN_TRUE];
  +    private static Integer INT_FALSE          = INT_CONSTANTS[SchemaSymbols.BOOLEAN_FALSE];
  +    private static Integer INT_QUALIFIED      = INT_CONSTANTS[SchemaSymbols.FORM_QUALIFIED];
  +    private static Integer INT_UNQUALIFIED    = INT_CONSTANTS[SchemaSymbols.FORM_UNQUALIFIED];
  +    private static Integer INT_EMPTY_SET      = INT_CONSTANTS[SchemaSymbols.EMPTY_SET];
  +    private static Integer INT_ANY_STRICT     = INT_CONSTANTS[SchemaSymbols.ANY_STRICT];
  +    private static Integer INT_ANY_LAX        = INT_CONSTANTS[SchemaSymbols.ANY_LAX];
  +    private static Integer INT_ANY_SKIP       = INT_CONSTANTS[SchemaSymbols.ANY_SKIP];
  +    private static Integer INT_USE_OPTIONAL   = INT_CONSTANTS[SchemaSymbols.USE_OPTIONAL];
  +    private static Integer INT_USE_REQUIRED   = INT_CONSTANTS[SchemaSymbols.USE_REQUIRED];
  +    private static Integer INT_USE_PROHIBITED = INT_CONSTANTS[SchemaSymbols.USE_PROHIBITED];
  +    private static Integer INT_WS_PRESERVE    = INT_CONSTANTS[SchemaSymbols.WS_PRESERVE];
  +    private static Integer INT_WS_REPLACE     = INT_CONSTANTS[SchemaSymbols.WS_REPLACE];
  +    private static Integer INT_WS_COLLAPSE    = INT_CONSTANTS[SchemaSymbols.WS_COLLAPSE];
  +    private static Integer INT_UNBOUNDED      = INT_CONSTANTS[SchemaSymbols.OCCURRENCE_UNBOUNDED];
   
       // the prefix to distinguish gloval vs. local; name vs. ref
       protected static String PRE_GLOBAL      = "G_";
  @@ -209,187 +231,141 @@
           OneAttr[] allAttrs = new OneAttr[attCount];
           allAttrs[ATT_ABSTRACT_D]        =   new OneAttr(SchemaSymbols.ATT_ABSTRACT,
                                                           DT_BOOLEAN,
  -                                                        ATT_OPT_DFLT,
  -                                                        Boolean.FALSE);
  +                                                        INTD_FALSE);
           allAttrs[ATT_ATTRIBUTE_FD_D]    =   new OneAttr(SchemaSymbols.ATT_ATTRIBUTEFORMDEFAULT,
                                                           DT_FORM,
  -                                                        ATT_OPT_DFLT,
  -                                                        FORM_UNQUALIFIED);
  +                                                        INTD_UNQUALIFIED);
           allAttrs[ATT_BASE_R]            =   new OneAttr(SchemaSymbols.ATT_BASE,
                                                           DT_QNAME,
  -                                                        ATT_REQUIRED,
                                                           null);
           allAttrs[ATT_BASE_N]            =   new OneAttr(SchemaSymbols.ATT_BASE,
                                                           DT_QNAME,
  -                                                        ATT_OPT_NODFLT,
                                                           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,
  -                                                        INT_EMPTY_SET);
  +                                                        INTD_EMPTY_SET);
           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,
  -                                                        FORM_UNQUALIFIED);
  +                                                        INTD_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,
  -                                                        INT_EMPTY_SET);
  +                                                        INTD_EMPTY_SET);
           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,
  -                                                        Boolean.FALSE);
  +                                                        INTD_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,
  -                                                        INT_ONE);
  +                                                        INTD_ONE);
           allAttrs[ATT_MAXOCCURS1_D]      =   new OneAttr(SchemaSymbols.ATT_MAXOCCURS,
                                                           DT_MAXOCCURS1,
  -                                                        ATT_OPT_DFLT,
  -                                                        INT_ONE);
  +                                                        INTD_ONE);
           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,
  -                                                        INT_ONE);
  +                                                        INTD_ONE);
           allAttrs[ATT_MINOCCURS1_D]      =   new OneAttr(SchemaSymbols.ATT_MINOCCURS,
                                                           DT_MINOCCURS1,
  -                                                        ATT_OPT_DFLT,
  -                                                        INT_ONE);
  +                                                        INTD_ONE);
           allAttrs[ATT_MIXED_D]           =   new OneAttr(SchemaSymbols.ATT_MIXED,
                                                           DT_BOOLEAN,
  -                                                        ATT_OPT_DFLT,
  -                                                        Boolean.FALSE);
  +                                                        INTD_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,
  -                                                        Boolean.FALSE);
  +                                                        INTD_FALSE);
           allAttrs[ATT_PROCESS_C_D]       =   new OneAttr(SchemaSymbols.ATT_PROCESSCONTENTS,
                                                           DT_PROCESSCONTENTS,
  -                                                        ATT_OPT_DFLT,
  -                                                        INT_ANY_STRICT);
  +                                                        INTD_ANY_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,
  -                                                        INT_USE_OPTIONAL);
  +                                                        INTD_USE_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);
           allAttrs[ATT_XPATH1_R]          =   new OneAttr(SchemaSymbols.ATT_XPATH,
                                                           DT_XPATH1,
  -                                                        ATT_REQUIRED,
                                                           null);
   
           // step 4: for each element, make a list of possible attributes
  @@ -887,6 +863,9 @@
       // used to store all seen ID values, and to check duplicate ID values
       private Hashtable fIdDefs = new Hashtable();
   
  +    // used to resolver namespace prefixes
  +    protected XSDHandler fSchemaHandler = null;
  +
       // used to store utility reference: error reproter. set via constructor.
       protected XMLErrorReporter fErrorReporter = null;
   
  @@ -894,8 +873,10 @@
       protected Hashtable fNonSchemaAttrs = new Hashtable();
   
       // constructor. Sets fErrorReproter and get datatype validators
  -    public XSAttributeChecker (DatatypeValidatorFactoryImpl datatypeRegistry,
  +    public XSAttributeChecker (XSDHandler schemaHandler,
  +                               DatatypeValidatorFactoryImpl datatypeRegistry,
                                  XMLErrorReporter er) {
  +        fSchemaHandler = schemaHandler;
           fErrorReporter = er;
           synchronized (getClass()) {
               if (fExtraDVs[DT_ANYURI] == null) {
  @@ -942,7 +923,10 @@
   
           // if the parent is xs:appInfo or xs:documentation,
           // then skip the validation, and return am empty list
  -        Element parent = DOMUtil.getParent(element);
  +        // REVISIT: it should be the XSDHandler's repsonsibility for not
  +        // calling XSAttributeChecker for the children of
  +        // appinfo and documentation
  +        /*Element parent = DOMUtil.getParent(element);
           if (parent != null) {
               String pUri = DOMUtil.getNamespaceURI(parent);
               String pName = DOMUtil.getLocalName(parent);
  @@ -951,7 +935,7 @@
                    pName.equals(SchemaSymbols.ELT_DOCUMENTATION))) {
                   return new Hashtable();
               }
  -        }
  +        }*/
   
           String uri = DOMUtil.getNamespaceURI(element);
           String elName = DOMUtil.getLocalName(element), name;
  @@ -997,7 +981,7 @@
               // skip anything starts with x/X m/M l/L
               // simply put their values in the return hashtable
               if (attrName.toLowerCase().startsWith("xml")) {
  -                attrValues.put(attrName, new AttrVal(attrVal, false));
  +                attrValues.put(attrName, attrVal);
                   continue;
               }
   
  @@ -1016,7 +1000,7 @@
                       // for attributes from other namespace
                       // store them in a list, and TRY to validate them after
                       // schema traversal (because it's "lax")
  -                    attrValues.put(attrName, new AttrVal(attrVal, false));
  +                    attrValues.put(attrName, attrVal);
                       String attrRName = attrURI + "," + attrName;
                       Vector values = (Vector)fNonSchemaAttrs.get(attrRName);
                       if (values == null) {
  @@ -1067,30 +1051,30 @@
                       case DT_BOOLEAN:
                           retValue = attrVal.equals(SchemaSymbols.ATTVAL_TRUE) ||
                                      attrVal.equals(SchemaSymbols.ATTVAL_TRUE_1) ?
  -                                   Boolean.TRUE : Boolean.FALSE;
  +                                   INT_TRUE : INT_FALSE;
                           break;
                       case DT_NONNEGINT:
                           retValue = new Integer(attrVal);
                           break;
                       case DT_QNAME:
  -                        //REVISIT: return QName
  -                        //retValue = new QName();
  -                        retValue = attrVal;
  +                        retValue = resolveQName(attrVal);
                           break;
                       default:
                           retValue = attrVal;
                           break;
                       }
  -                    attrValues.put(attrName, new AttrVal(retValue, false));
  +                    attrValues.put(attrName, retValue);
                   }
                   else {
                       retValue = validate(attrName, attrVal, oneAttr.dvIndex);
  -                    attrValues.put(attrName, new AttrVal(retValue, false));
  +                    attrValues.put(attrName, retValue);
                   }
               }
               catch (InvalidDatatypeValueException ide) {
                   reportSchemaError ("Con3X3AttributeInvalidValue",
                                      new Object[] {elName, attrName, ide.getLocalizedMessage()});
  +                if (oneAttr.dfltValue != null)
  +                    attrValues.put(attrName, oneAttr.dfltValue);
               }
           }
   
  @@ -1103,14 +1087,9 @@
               if (DOMUtil.getAttr(element, oneAttr.name) != null)
                   continue;
   
  -            // if the attribute is required, report an error
  -            if (oneAttr.optdflt == ATT_REQUIRED) {
  -                reportSchemaError ("Con3X3AttributeMustAppear",
  -                                   new Object[] {elName, oneAttr.name});
  -            }
               // if the attribute is optional with default value, apply it
  -            else if (oneAttr.optdflt == ATT_OPT_DFLT) {
  -                attrValues.put(oneAttr.name, new AttrVal(oneAttr.dfltValue, true));
  +            else if (oneAttr.dfltValue != null) {
  +                attrValues.put(oneAttr.name, oneAttr.dfltValue);
               }
           }
   
  @@ -1211,9 +1190,9 @@
           case DT_FORM:
               // form = (qualified | unqualified)
               if (value.equals (SchemaSymbols.ATTVAL_QUALIFIED))
  -                retValue = FORM_QUALIFIED;
  +                retValue = INT_QUALIFIED;
               else if (value.equals (SchemaSymbols.ATTVAL_UNQUALIFIED))
  -                retValue = FORM_UNQUALIFIED;
  +                retValue = INT_UNQUALIFIED;
               else
                   throw new InvalidDatatypeValueException("the value '"+value+"' must match (qualified | unqualified)");
               break;
  @@ -1250,9 +1229,7 @@
                       retValue = fExtraDVs[DT_QNAME].validate(token, null);
                       // REVISIT: should have the datatype validators return
                       // the object representation of the value.
  -                    // REVISIT: return QName
  -                    // retValue = new QName();
  -                    retValue = token;
  +                    retValue = resolveQName(token);
                       memberType.addElement(retValue);
                   }
                   retValue = memberType;
  @@ -1439,6 +1416,18 @@
   
           return sb.toString();
       }
  +
  +    protected QName resolveQName (String attrVal) {
  +        String prefix = "";
  +        String localpart = attrVal;
  +        int colonptr = attrVal.indexOf(":");
  +        if ( colonptr > 0) {
  +            prefix = attrVal.substring(0,colonptr);
  +            localpart = attrVal.substring(colonptr+1);
  +        }
  +        String uri = fSchemaHandler.resolvePrefixToURI(prefix);
  +        return new QName(prefix, localpart, attrVal, uri);
  +    }
   }
   
   class OneAttr {
  @@ -1451,10 +1440,9 @@
       // the default value of this attribute
       public Object dfltValue;
   
  -    public OneAttr(String name, int dvIndex, int optdflt, Object dfltValue) {
  +    public OneAttr(String name, int dvIndex, Object dfltValue) {
           this.name = name;
           this.dvIndex = dvIndex;
  -        this.optdflt = optdflt;
           this.dfltValue = dfltValue;
       }
   }
  
  
  
  1.3       +405 -5    xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java
  
  Index: XSDElementTraverser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDElementTraverser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSDElementTraverser.java	2001/08/24 23:00:36	1.2
  +++ XSDElementTraverser.java	2001/08/28 19:57:46	1.3
  @@ -57,6 +57,8 @@
   package org.apache.xerces.impl.v2;
   
   import  org.apache.xerces.impl.XMLErrorReporter;
  +import  org.apache.xerces.util.DOMUtil;
  +import  org.apache.xerces.xni.QName;
   import  org.w3c.dom.Element;
   import java.util.Hashtable;
   
  @@ -82,10 +84,21 @@
    *   Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))
    * </element>
    *
  - * @version $Id: XSDElementTraverser.java,v 1.2 2001/08/24 23:00:36 sandygao Exp $
  + * @version $Id: XSDElementTraverser.java,v 1.3 2001/08/28 19:57:46 sandygao Exp $
    */
   class XSDElementTraverser extends XSDAbstractTraverser{
   
  +    protected static final QName ANY_TYPE        = new QName(null,
  +                                                             SchemaSymbols.ATTVAL_ANYTYPE,
  +                                                             SchemaSymbols.ATTVAL_ANYTYPE,
  +                                                             SchemaSymbols.URI_SCHEMAFORSCHEMA);
  +    protected static final QName ANY_SIMPLE_TYPE = new QName(null,
  +                                                             SchemaSymbols.ATTVAL_ANYSIMPLETYPE,
  +                                                             SchemaSymbols.ATTVAL_ANYTYPE,
  +                                                             SchemaSymbols.URI_SCHEMAFORSCHEMA);
  +
  +    protected XSElementDecl fTempElementDecl = new XSElementDecl();
  +
       //
       // REVISIT: we should be able to acces
       // SubstitutionGroupHandler
  @@ -97,20 +110,407 @@
           super(handler, errorReporter, gAttrCheck);
       }
   
  +    /**
  +     * Traverse a locally declared element (or an element reference).
  +     *
  +     * To handle the recursive cases effeciently, we delay the traversal
  +     * and return an empty particle node. We'll fill in this particle node
  +     * later after we've done with all the global declarations.
  +     *
  +     * @param  elmDecl
  +     * @param  schemaDoc
  +     * @param  grammar
  +     * @return the particle node index
  +     */
  +    int traverseLocal(Element elmDecl,
  +                      XSDocumentInfo schemaDoc,
  +                      SchemaGrammar grammar) {
  +        return -1;
  +    }
   
  -    int traverse(Element elmDecl,
  -                 XSDocumentInfo schemaDoc,
  -                 SchemaGrammar grammar) {
  +    /**
  +     * Traverse a locally declared element (or an element reference).
  +     *
  +     * This is the real traversal method. It's called after we've done with
  +     * all the global declarations.
  +     *
  +     * @param  particleIdx
  +     * @param  elmDecl
  +     * @param  attrValues
  +     * @param  schemaDoc
  +     * @param  grammar
  +     * @return the particle node index
  +     */
  +    int traverseLocal(int particleIdx,
  +                      Element elmDecl,
  +                      Hashtable attrValues,
  +                      XSDocumentInfo schemaDoc,
  +                      SchemaGrammar grammar) {
           return -1;
       }
   
  +    /**
  +     * Traverse a globally declared element.
  +     *
  +     * @param  elmDecl
  +     * @param  schemaDoc
  +     * @param  grammar
  +     * @return the element declaration index
  +     */
       int traverseGlobal(Element elmDecl,
                          XSDocumentInfo schemaDoc,
                          SchemaGrammar grammar) {
  -        return -1;
  +
  +        // General Attribute Checking
  +        Hashtable attrValues = fAttrChecker.checkAttributes(elmDecl, true);
  +
  +        return traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, true);
       }
   
  +    /**
  +     * Traverse a globally declared element.
  +     *
  +     * @param  elmDecl
  +     * @param  attrValues
  +     * @param  schemaDoc
  +     * @param  grammar
  +     * @param  isGlobal
  +     * @return the element declaration index
  +     */
  +    int traverseNamedElement(Element elmDecl,
  +                             Hashtable attrValues,
  +                             XSDocumentInfo schemaDoc,
  +                             SchemaGrammar grammar,
  +                             boolean isGlobal) {
  +
  +        Integer abstractAtt  = (Integer) attrValues.get(SchemaSymbols.ATT_ABSTRACT);
  +        Integer blockAtt     = (Integer) attrValues.get(SchemaSymbols.ATT_BLOCK);
  +        String  defaultAtt   = (String)  attrValues.get(SchemaSymbols.ATT_DEFAULT);
  +        Integer finalAtt     = (Integer) attrValues.get(SchemaSymbols.ATT_FINAL);
  +        String  fixedAtt     = (String)  attrValues.get(SchemaSymbols.ATT_FIXED);
  +        Integer formAtt      = (Integer) attrValues.get(SchemaSymbols.ATT_FORM);
  +        String  nameAtt      = (String)  attrValues.get(SchemaSymbols.ATT_NAME);
  +        Integer nillableAtt  = (Integer) attrValues.get(SchemaSymbols.ATT_NILLABLE);
  +        QName   refAtt       = (QName)   attrValues.get(SchemaSymbols.ATT_REF);
  +        QName   subGroupAtt  = (QName)   attrValues.get(SchemaSymbols.ATT_SUBSTITUTIONGROUP);
  +        QName   typeAtt      = (QName)   attrValues.get(SchemaSymbols.ATT_TYPE);
  +
  +        //REVISIT: notation datatype error checking
  +        //checkEnumerationRequiredNotation(nameStr, typeStr);
  +
  +		if (defaultAtt != null && fixedAtt != null) {
  +			// REVISIT:  localize
  +			reportGenericSchemaError("src-element.1: an element cannot have both \"fixed\" and \"default\" present at the same time");
  +        }
  +
  +        if (nameAtt == null) {
  +            // REVISIT: Localize
  +            if (isGlobal)
  +                reportGenericSchemaError("globally-declared element must have a name");
  +            else
  +                reportGenericSchemaError("src-element.2.1: a local element must have a name or a ref attribute present");
  +        }
  +
  +        // parse out 'block', 'final', 'nillable', 'abstract'
  +        short blockSet = blockAtt == null ? SchemaSymbols.EMPTY_SET : blockAtt.shortValue();
  +        short finalSet = finalAtt == null ? SchemaSymbols.EMPTY_SET : finalAtt.shortValue();
  +        short elementMiscFlags = 0;
  +        if ((nillableAtt.intValue() & SchemaSymbols.REAL_VALUE) == SchemaSymbols.BOOLEAN_TRUE)
  +            elementMiscFlags |= XSElementDecl.NILLABLE;
  +        if ((abstractAtt.intValue() & SchemaSymbols.REAL_VALUE) == SchemaSymbols.BOOLEAN_TRUE)
  +            elementMiscFlags |= XSElementDecl.ABSTRACT;
  +        // make the property of the element's value being fixed also appear in elementMiscFlags
  +        if (fixedAtt != null)
  +            elementMiscFlags |= XSElementDecl.FIXED;
  +
  +        // element has a single child element, either a datatype or a type, null if primitive
  +        Element child = DOMUtil.getFirstChildElement(elmDecl);
  +
  +        if(child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
  +			traverseAnnotationDecl(child, attrValues);
  +            child = DOMUtil.getNextSiblingElement(child);
  +		}
  +        if(child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION))
  +            // REVISIT: Localize
  +            reportGenericSchemaError("element declarations can contain at most one annotation Element Information Item");
  +
  +        int elementType = -1;
  +
  +        boolean noErrorSoFar = true;
  +        boolean haveAnonType = false;
  +
  +        // Handle Anonymous type if there is one
  +        if (child != null) {
  +            String childName = DOMUtil.getLocalName(child);
  +
  +            if (childName.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
  +                // Determine what the type name will be
  +                elementType = fSchemaHandler.fComplexTypeTraverser.traverse(child, schemaDoc, grammar, null);
  +                if (elementType == -1 ) {
  +                    noErrorSoFar = false;
  +                    // REVISIT: Localize
  +                    reportGenericSchemaError("traverse complexType error in element '" + nameAtt +"'");
  +                }
  +                haveAnonType = true;
  +            	child = DOMUtil.getNextSiblingElement(child);
  +            }
  +            else if (childName.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
  +                elementType = fSchemaHandler.fSimpleTypeTraverser.traverse(child, schemaDoc, grammar);
  +                if (elementType == -1) {
  +                    noErrorSoFar = false;
  +                    // REVISIT: Localize
  +                    reportGenericSchemaError("traverse simpleType error in element '" + nameAtt +"'");
  +                }
  +                haveAnonType = true;
  +            	child = DOMUtil.getNextSiblingElement(child);
  +            }
  +
  +			// see if there's something here; it had better be key, keyref or unique.
  +			if (child != null)
  +                childName = DOMUtil.getLocalName(child);
  +			while ((child != null) && ((childName.equals(SchemaSymbols.ELT_KEY))
  +                    || (childName.equals(SchemaSymbols.ELT_KEYREF))
  +                    || (childName.equals(SchemaSymbols.ELT_UNIQUE)))) {
  +            	child = DOMUtil.getNextSiblingElement(child);
  +                if (child != null) {
  +                    childName = DOMUtil.getLocalName(child);
  +                }
  +			}
  +			if (child != null) {
  +               	// REVISIT: Localize
  +            	noErrorSoFar = false;
  +                reportGenericSchemaError("src-element.0: the content of an element information item must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)");
  +			}
  +        }
  +
  +        // handle type="" here
  +        if (haveAnonType && (typeAtt != null)) {
  +            noErrorSoFar = false;
  +            // REVISIT: Localize
  +            reportGenericSchemaError( "src-element.3: Element '"+ nameAtt +
  +                                      "' have both a type attribute and a annoymous type child" );
  +        }
  +        // type specified as an attribute and no child is type decl.
  +        else if (!haveAnonType && typeAtt != null) {
  +            elementType = fSchemaHandler.getTypeDecl(typeAtt.uri, typeAtt.localpart);
  +            if (elementType == -1) {
  +                noErrorSoFar = false;
  +                reportGenericSchemaError("type not found: "+typeAtt.uri+":"+typeAtt.localpart);
  +            }
  +        }
   
  +        // Handle the substitutionGroup
  +        String subGroupNS = null;
  +        int subGroupIndex = -1;
  +/*        Element substitutionGroupElementDecl = null;
  +        int substitutionGroupElementDeclIndex = -1;
  +
  +        // now we need to make sure that our substitution (if any)
  +        // is valid, now that we have all the requisite type-related info.
  +        String substitutionGroupUri = null;
  +        String substitutionGroupLocalpart = null;
  +        String substitutionGroupFullName = null;
  +        ComplexTypeInfo substitutionGroupEltTypeInfo = null;
  +        DatatypeValidator substitutionGroupEltDV = null;
  +        SchemaGrammar subGrammar = fSchemaGrammar;
  +        boolean ignoreSub = false;
  +
  +        if ( substitutionGroupStr.length() > 0 ) {
  +            if(refAtt != null)
  +                // REVISIT: Localize
  +                reportGenericSchemaError("a local element cannot have a substitutionGroup");
  +            substitutionGroupUri =  resolvePrefixToURI(getPrefix(substitutionGroupStr));
  +            substitutionGroupLocalpart = getLocalPart(substitutionGroupStr);
  +            substitutionGroupFullName = substitutionGroupUri+","+substitutionGroupLocalpart;
  +
  +            if ( !substitutionGroupUri.equals(fTargetNSURIString) ) {
  +                Grammar grammar = fGrammarResolver.getGrammar(substitutionGroupUri);
  +                if (grammar != null && grammar instanceof SchemaGrammar) {
  +                    subGrammar = (SchemaGrammar) grammar;
  +                    substitutionGroupElementDeclIndex = subGrammar.getElementDeclIndex(fStringPool.addSymbol(substitutionGroupUri),
  +                                                              fStringPool.addSymbol(substitutionGroupLocalpart),
  +                                                              TOP_LEVEL_SCOPE);
  +                    if (substitutionGroupElementDeclIndex<=-1) {
  +                        // REVISIT:  localize
  +                        noErrorSoFar = false;
  +                        reportGenericSchemaError("couldn't find substitutionGroup " + substitutionGroupLocalpart + " referenced by element " + nameStr
  +                                         + " in the SchemaGrammar "+substitutionGroupUri);
  +
  +                    } else {
  +                        substitutionGroupEltTypeInfo = getElementDeclTypeInfoFromNS(substitutionGroupUri, substitutionGroupLocalpart);
  +                        if (substitutionGroupEltTypeInfo == null) {
  +                            substitutionGroupEltDV = getElementDeclTypeValidatorFromNS(substitutionGroupUri, substitutionGroupLocalpart);
  +                            //if (substitutionGroupEltDV == null) {
  +                                //TO DO: report error here;
  +                                //noErrorSoFar = false;
  +                                //reportGenericSchemaError("Could not find type for element '" +substitutionGroupLocalpart
  +                                //                 + "' in schema '" + substitutionGroupUri+"'");
  +                            //}
  +                        }
  +                    }
  +                } else {
  +                    // REVISIT:  locallize
  +                    noErrorSoFar = false;
  +                    reportGenericSchemaError("couldn't find a schema grammar with target namespace '" + substitutionGroupUri + "' for element '" + substitutionGroupStr + "'");
  +                }
  +            }
  +            else {
  +                substitutionGroupElementDecl = getTopLevelComponentByName(SchemaSymbols.ELT_ELEMENT, substitutionGroupLocalpart);
  +                if (substitutionGroupElementDecl == null) {
  +                    substitutionGroupElementDeclIndex =
  +                        fSchemaGrammar.getElementDeclIndex(fTargetNSURI, getLocalPartIndex(substitutionGroupStr),TOP_LEVEL_SCOPE);
  +                    if ( substitutionGroupElementDeclIndex == -1) {
  +                        noErrorSoFar = false;
  +                        // REVISIT: Localize
  +                        reportGenericSchemaError("unable to locate substitutionGroup affiliation element "
  +                                                  +substitutionGroupStr
  +                                                  +" in element declaration "
  +                                                  +nameStr);
  +                    }
  +                }
  +                else {
  +                    substitutionGroupElementDeclIndex =
  +                        fSchemaGrammar.getElementDeclIndex(fTargetNSURI, getLocalPartIndex(substitutionGroupStr),TOP_LEVEL_SCOPE);
  +
  +                    if ( substitutionGroupElementDeclIndex == -1) {
  +                        // check for mutual recursion!
  +                        if(fSubstitutionGroupRecursionRegistry.contains(fTargetNSURIString+","+substitutionGroupElementDecl.getAttribute(SchemaSymbols.ATT_NAME))) {
  +                            ignoreSub = true;
  +                        } else {
  +                            fSubstitutionGroupRecursionRegistry.addElement(fTargetNSURIString+","+substitutionGroupElementDecl.getAttribute(SchemaSymbols.ATT_NAME));
  +                            traverseElementDecl(substitutionGroupElementDecl);
  +                            substitutionGroupElementDeclIndex =
  +                                fSchemaGrammar.getElementDeclIndex(fTargetNSURI, getLocalPartIndex(substitutionGroupStr),TOP_LEVEL_SCOPE);
  +                            fSubstitutionGroupRecursionRegistry.removeElement((Object)fTargetNSURIString+","+substitutionGroupElementDecl.getAttribute(SchemaSymbols.ATT_NAME));
  +                        }
  +                    }
  +                }
  +
  +                if (!ignoreSub && substitutionGroupElementDeclIndex != -1) {
  +                    substitutionGroupEltTypeInfo = fSchemaGrammar.getElementComplexTypeInfo( substitutionGroupElementDeclIndex );
  +                    if (substitutionGroupEltTypeInfo == null) {
  +                        fSchemaGrammar.getElementDecl(substitutionGroupElementDeclIndex, fTempElementDecl);
  +                        substitutionGroupEltDV = fTempElementDecl.datatypeValidator;
  +                        //if (substitutionGroupEltDV == null) {
  +                            //TO DO: report error here;
  +                            //noErrorSoFar = false;
  +                            //reportGenericSchemaError("Could not find type for element '" +substitutionGroupLocalpart
  +                            //                         + "' in schema '" + substitutionGroupUri+"'");
  +                        //}
  +                    }
  +                }
  +            }
  +            if (substitutionGroupElementDeclIndex <= -1)
  +                ignoreSub = true;
  +            if(!ignoreSub)
  +                checkSubstitutionGroupOK(elementDecl, substitutionGroupElementDecl, noErrorSoFar, substitutionGroupElementDeclIndex, subGrammar, typeInfo, substitutionGroupEltTypeInfo, dv, substitutionGroupEltDV);
  +        }
  +
  +        // this element is ur-type, check its substitutionGroup affiliation.
  +        // if there is substitutionGroup affiliation and not type definition found for this element,
  +        // then grab substitutionGroup affiliation's type and give it to this element
  +        if ( noErrorSoFar && typeInfo == null && dv == null ) {
  +			typeInfo = substitutionGroupEltTypeInfo;
  +			dv = substitutionGroupEltDV;
  +        }*/
  +
  +        if (elementType == -1 && noErrorSoFar) {
  +            elementType = fSchemaHandler.getTypeDecl(ANY_TYPE.uri, ANY_TYPE.localpart);
  +        }
  +
  +        // Now we can handle validation etc. of default and fixed attributes,
  +        // since we finally have all the type information.
  +        /*if (fixedAtt != null)
  +            defaultAtt = fixedAtt;
  +        if (defaultAtt.length() != 0) {
  +            // REVISIT: get type declaration
  +            // check whether it's complex
  +            // if so, check whether mixed or simple contnet
  +            // if mixed, check whether it's emptible
  +            if(typeInfo != null &&
  +                    (typeInfo.contentType != XMLElementDecl.TYPE_MIXED_SIMPLE &&
  +                     typeInfo.contentType != XMLElementDecl.TYPE_MIXED_COMPLEX &&
  +                    typeInfo.contentType != XMLElementDecl.TYPE_SIMPLE)) {
  +                // REVISIT: Localize
  +                reportGenericSchemaError ("e-props-correct.2.1: element " + nameStr + " has a fixed or default value and must have a mixed or simple content model");
  +            }
  +            if(typeInfo != null &&
  +               (typeInfo.contentType == XMLElementDecl.TYPE_MIXED_SIMPLE ||
  +                typeInfo.contentType == XMLElementDecl.TYPE_MIXED_COMPLEX)) {
  +                if (!particleEmptiable(typeInfo.contentSpecHandle))
  +                    reportGenericSchemaError ("e-props-correct.2.2.2: for element " + nameStr + ", the {content type} is mixed, then the {content type}'s particle must be emptiable");
  +            }
  +
  +            // get the simple type delaration, and validate
  +            try {
  +                if(dv != null) {
  +                    dv.validate(defaultStr, null);
  +                }
  +            } catch (InvalidDatatypeValueException ide) {
  +                reportGenericSchemaError ("e-props-correct.2: invalid fixed or default value '" + defaultStr + "' in element " + nameStr);
  +            }
  +        }
  +
  +        // check whether ID type has a default/fixed value
  +        if (defaultStr.length() != 0 &&
  +            dv != null && dv instanceof IDDatatypeValidator) {
  +            reportGenericSchemaError ("e-props-correct.4: If the {type definition} or {type definition}'s {content type} is or is derived from ID then there must not be a {value constraint} -- element " + nameStr);
  +        }*/
  +
  +        //
  +        // Create element decl
  +        //
  +
  +        String namespace = "";
  +        if (isGlobal) {
  +            namespace = schemaDoc.fTargetNamespace;
  +        }
  +        else if ((formAtt.intValue() & SchemaSymbols.REAL_VALUE) == SchemaSymbols.FORM_QUALIFIED ||
  +                 schemaDoc.fAreLocalElementsQualified) {
  +            namespace = schemaDoc.fTargetNamespace;
  +        }
  +
  +        // add element decl to the registry
  +        fTempElementDecl.fQName.setValues(null, nameAtt, nameAtt, namespace);
  +        fTempElementDecl.fTypeNS = typeAtt == null ? schemaDoc.fTargetNamespace : typeAtt.uri;
  +        fTempElementDecl.fXSTypeDecl = elementType;
  +        fTempElementDecl.fElementMiscFlags = elementMiscFlags;
  +        fTempElementDecl.fBlock = blockSet;
  +        fTempElementDecl.fFinal = finalSet;
  +        fTempElementDecl.fDefault = defaultAtt;
  +        fTempElementDecl.fSubGroupNS = subGroupNS;
  +        fTempElementDecl.fSubGroupIdx = subGroupIndex;
  +        int elementIndex = grammar.addElementDecl(fTempElementDecl);
  +
  +        // REVISIT: process of substitutionGroup and idendity constraint
  +        // substitutionGroup: double-direction
  +        /*if (subGroupAtt != null && !ignoreSub) {
  +            fSchemaHandler.addElementDeclOneSubstitutionGroupQName(substitutionGroupElementDeclIndex, eltQName, fSchemaGrammar, elementIndex);
  +        }
  +
  +        //
  +        // key/keyref/unique processing
  +        //
  +
  +        Element ic = XUtil.getFirstChildElementNS(elementDecl, IDENTITY_CONSTRAINTS);
  +        if (ic != null) {
  +            Integer elementIndexObj = new Integer(elementIndex);
  +            Vector identityConstraints = (Vector)fIdentityConstraints.get(elementIndexObj);
  +            if (identityConstraints == null) {
  +                identityConstraints = new Vector();
  +                fIdentityConstraints.put(elementIndexObj, identityConstraints);
  +            }
  +            while (ic != null) {
  +                if (DEBUG_IC_DATATYPES) {
  +                    System.out.println("<ICD>: adding ic for later traversal: "+ic);
  +                }
  +                identityConstraints.addElement(ic);
  +                ic = XUtil.getNextSiblingElementNS(ic, IDENTITY_CONSTRAINTS);
  +            }
  +        }*/
  +
  +        return elementIndex;
  +    }
   
       //private help functions
   
  
  
  
  1.10      +28 -28    xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java
  
  Index: XSDHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSDHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XSDHandler.java	2001/08/28 18:50:48	1.9
  +++ XSDHandler.java	2001/08/28 19:57:46	1.10
  @@ -86,7 +86,7 @@
    * schema, other grammars may be constructed as a side-effect.
    *
    * @author Neil Graham, IBM
  - * @version $Id: XSDHandler.java,v 1.9 2001/08/28 18:50:48 neilg Exp $
  + * @version $Id: XSDHandler.java,v 1.10 2001/08/28 19:57:46 sandygao Exp $
    */
   
   class XSDHandler {
  @@ -154,8 +154,8 @@
       // the primary XSDocumentInfo we were called to parse
       private XSDocumentInfo fRoot = null;
   
  -    // map between <redefine> elements and the XSDocumentInfo 
  -    // objects that correspond to the documents being redefined.  
  +    // map between <redefine> elements and the XSDocumentInfo
  +    // objects that correspond to the documents being redefined.
       private Hashtable fRedefine2XSDMap = new Hashtable();
   
       // the XMLErrorReporter
  @@ -254,7 +254,7 @@
                                           XSDocumentInfo(schemaRoot);
           Vector dependencies = new Vector();
           Element rootNode = DOMUtil.getRoot(schemaRoot);
  -        String schemaNamespace=EMPTY_STRING;        
  +        String schemaNamespace=EMPTY_STRING;
           String schemaHint=null;
           Document newSchemaRoot = null;
           for (Element child =
  @@ -308,7 +308,7 @@
            * set its Document node to hidden so that we don't try to traverse
            * it again; then we look to its Dependency map entry.  We keep a
            * stack of schemas that we haven't yet finished processing; this
  -         * is a depth-first traversal.  
  +         * is a depth-first traversal.
            */
           Stack schemasToProcess = new Stack();
           schemasToProcess.push(fRoot);
  @@ -347,7 +347,7 @@
                       for(Element redefineComp = DOMUtil.getFirstChildElement(globalComp);
                               redefineComp != null;
                               redefineComp = DOMUtil.getNextSiblingElement(redefineComp)) {
  -                        String lName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME); 
  +                        String lName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME);
                           if(lName.length() == 0) // an error we'll catch later
                               continue;
                           String qName = currSchemaDoc.fTargetNamespace +","+lName;
  @@ -355,32 +355,32 @@
                           if(componentType.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
                               checkForDuplicateNames(qName, fUnparsedAttributeGroupRegistry, globalComp, currSchemaDoc);
                               // the check will have changed our name;
  -                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME); 
  +                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME);
                               // and all we need to do is error-check+rename our kkids:
                               // REVISIT!!!
  -//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_ATTRIBUTEGROUP), 
  +//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_ATTRIBUTEGROUP),
   //                                lName, targetLName);
                           } else if((componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) ||
                                   (componentType.equals(SchemaSymbols.ELT_SIMPLETYPE))) {
                               checkForDuplicateNames(qName, fUnparsedTypeRegistry, globalComp, currSchemaDoc);
                               // the check will have changed our name;
  -                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME); 
  +                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME);
                               // and all we need to do is error-check+rename our kkids:
                               // REVISIT!!!
                               if(componentType.equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
  -//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_COMPLEXTYPE), 
  +//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_COMPLEXTYPE),
   //                                lName, targetLName);
                               } else { // must be simpleType
  -//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_SIMPLETYPE), 
  +//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_SIMPLETYPE),
   //                                lName, targetLName);
                               }
                           } else if(componentType.equals(SchemaSymbols.ELT_GROUP)) {
                               checkForDuplicateNames(qName, fUnparsedGroupRegistry, globalComp, currSchemaDoc);
                               // the check will have changed our name;
  -                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME); 
  +                            String targetLName = DOMUtil.getAttrValue(redefineComp, SchemaSymbols.ATT_NAME);
                               // and all we need to do is error-check+rename our kkids:
                               // REVISIT!!!
  -//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_GROUP), 
  +//                            renameRedefiningComponents(redefineComp, SchemaSymbols.ELT_GROUP),
   //                                lName, targetLName);
                           } else {
                               // REVISIT:  report schema element ordering error
  @@ -390,7 +390,7 @@
                       DOMUtil.setHidden(globalComp);
                   } else {
                       dependenciesCanOccur = false;
  -                    String lName = DOMUtil.getAttrValue(globalComp, SchemaSymbols.ATT_NAME); 
  +                    String lName = DOMUtil.getAttrValue(globalComp, SchemaSymbols.ATT_NAME);
                       if(lName.length() == 0) // an error we'll catch later
                           continue;
                       String qName = currSchemaDoc.fTargetNamespace +","+lName;
  @@ -420,8 +420,8 @@
               Vector currSchemaDepends = (Vector)fDependencyMap.get(currSchemaDoc);
               for(int i = 0; i < currSchemaDepends.size(); i++) {
                   schemasToProcess.push(currSchemaDepends.elementAt(i));
  -            } 
  -        } // while 
  +            }
  +        } // while
       } // end buildGlobalNameRegistries
   
       // Beginning at the first schema processing was requested for
  @@ -502,8 +502,7 @@
       // of this object; it creates the traversers that will be used to
       // construct schemaGrammars.
       private void createTraversers() {
  -        fAttributeChecker = new
  -                            XSAttributeChecker(fDatatypeRegistry, fErrorReporter);
  +        fAttributeChecker = new XSAttributeChecker(this, fDatatypeRegistry, fErrorReporter);
           fAttributeGroupTraverser = new
                                      XSDAttributeGroupTraverser(this, fErrorReporter, fAttributeChecker);
           fAttributeTraverser = new XSDAttributeTraverser(this,
  @@ -574,7 +573,7 @@
   
       protected void createSimpleType (String qualifiedName, DatatypeValidator baseValidator,
                                   Hashtable facetData, boolean isList){
  -        
  +
           try {
               fDatatypeRegistry.createDatatypeValidator( qualifiedName, baseValidator,
                                                          facetData, isList);
  @@ -585,7 +584,7 @@
           }
       }
       protected void createUnionSimpleType (String qualifiedName, Vector dTValidators){
  -        try{            
  +        try{
               fDatatypeRegistry.createDatatypeValidator( qualifiedName, dTValidators);
           }
           catch (Exception e) {
  @@ -593,14 +592,14 @@
               //reportSchemaError(SchemaMessageProvider.DatatypeError,new Object [] { e.getMessage()});
           }
       }
  -    
  -    /** This method makes sure that 
  +
  +    /** This method makes sure that
        * if this component is being redefined that it lives in the
        * right schema.  It then renames the component correctly.  If it
  -     * detects a collision--a duplicate definition--then it complains.  
  +     * detects a collision--a duplicate definition--then it complains.
        */
       private void checkForDuplicateNames(String qName,
  -            Hashtable registry, Element currComp, 
  +            Hashtable registry, Element currComp,
               XSDocumentInfo currSchema) {
           Object objElem = null;
           if((objElem = registry.get(qName)) == null) {
  @@ -619,10 +618,10 @@
                   // REVISIT:  error that redefined element in wrong schema
               } else { // we've just got a flat-out collision
                   // REVISIT:  report error for duplicate declarations
  -            } 
  +            }
           }
       } // checkForDuplicateNames(String, Hashtable, Element, XSDocumentInfo):void
  -    
  +
   
       //
       //!!!!!!!!!!!!!!!! IMPLEMENT the following functions !!!!!!!!!!
  @@ -643,13 +642,14 @@
           return null;
       }
   
  +
       // the purpose of this method is to take the component of the
       // specified type and rename references to itself so that they
       // refer to the object being redefined.  It takes special care of
       // <group>s and <attributeGroup>s to ensure that information
       // relating to implicit restrictions is preserved for those
  -    // traversers.  
  -    private void renameRedefiningComponents(Element component, String componentType, 
  +    // traversers.
  +    private void renameRedefiningComponents(Element component, String componentType,
               String oldName, String newName) {
       } // renameRedefiningComponents(Element, String, String, String):void
   
  
  
  
  1.3       +6 -6      xml-xerces/java/src/org/apache/xerces/impl/v2/XSElementDecl.java
  
  Index: XSElementDecl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/v2/XSElementDecl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSElementDecl.java	2001/08/27 15:21:37	1.2
  +++ XSElementDecl.java	2001/08/28 19:57:46	1.3
  @@ -63,7 +63,7 @@
   
   /**
    * The XML representation for an element declaration schema component is an <element> element information item
  - * @version $Id: XSElementDecl.java,v 1.2 2001/08/27 15:21:37 sandygao Exp $
  + * @version $Id: XSElementDecl.java,v 1.3 2001/08/28 19:57:46 sandygao Exp $
    */
   public class XSElementDecl {
   
  @@ -79,18 +79,18 @@
       public final QName fQName = new QName();
   
       // index to the type registry: simpleType or complexType
  +    public String fTypeNS;
       public int fXSTypeDecl;
   
       // nillable/abstract/final
       public short fElementMiscFlags;
   
  -    public String fBlock;
  -    public String fFinal;
  +    public short fBlock;
  +    public short fFinal;
       public String fDefault;
   
  -    // REVISIT: should we store Substitution group names?
  -    //
  -    public String fSubstitutionGroupName;
  +    public String fSubGroupNS;
  +    public int fSubGroupIdx;
   
       // REVISIT: should we expose more type information:
       // datatypeValidators or contentSpecIndex
  
  
  

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