xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema/identity Field.java Selector.java XPath.java XPathMatcher.java
Date Thu, 01 Feb 2001 09:58:48 GMT
andyc       01/02/01 01:58:47

  Modified:    java/src/org/apache/xerces/framework XMLAttrList.java
               java/src/org/apache/xerces/parsers SAXParser.java
               java/src/org/apache/xerces/readers AbstractCharReader.java
                        StreamingCharReader.java UCSReader.java
                        UTF8Reader.java
               java/src/org/apache/xerces/utils NamespacesScope.java
                        QName.java
               java/src/org/apache/xerces/validators/common
                        DFAContentModel.java Grammar.java
                        MixedContentModel.java XMLValidator.java
               java/src/org/apache/xerces/validators/dtd DTDGrammar.java
               java/src/org/apache/xerces/validators/schema
                        SchemaGrammar.java TraverseSchema.java
               java/src/org/apache/xerces/validators/schema/identity
                        Field.java Selector.java XPath.java
                        XPathMatcher.java
  Log:
  Some massive bug fixes. All subtle but very important.
  
  1) Fixed (hopefully all) inconsistencies with dealing with
     unbound QName URIs. Parts of the code used the identifier
     0 while other parts of the code use -1 and always mapped
     it to 0 before using it. As expected, this is a very
     fragile situation so I blitzed the code and changed all
     occurrences to 0 so that we're now consistent. This
     change touched a *lot* of files.
  2) Did some additional work on the identity constraint
     support. I'm working on a) enabling namespaces to work
     in identity constraints, and b) comparing field values
     in the values space instead of the lexical space which
     is the current implementation.
  
  Revision  Changes    Path
  1.6       +2 -2      xml-xerces/java/src/org/apache/xerces/framework/XMLAttrList.java
  
  Index: XMLAttrList.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/framework/XMLAttrList.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLAttrList.java	2000/10/31 17:40:06	1.5
  +++ XMLAttrList.java	2001/02/01 09:58:16	1.6
  @@ -94,7 +94,7 @@
    * may be used to access the attribute list through the SAX <code>AttributeList</code>
    * interface.
    *
  - * @version $Id: XMLAttrList.java,v 1.5 2000/10/31 17:40:06 jeffreyr Exp $
  + * @version $Id: XMLAttrList.java,v 1.6 2001/02/01 09:58:16 andyc Exp $
    */
   public final class XMLAttrList 
       implements AttributeList {
  @@ -367,7 +367,7 @@
               fAttPrefix[chunk][index] = -1;
               fAttLocalpart[chunk][index] = -1;
               fAttName[chunk][index] = -1;
  -            fAttURI[chunk][index] = -1;
  +            fAttURI[chunk][index] = StringPool.EMPTY_STRING;
               if ((fAttFlags[chunk][index] & ATTFLAG_SPECIFIED) != 0)
                   fStringPool.releaseString(fAttValue[chunk][index]);
               fAttValue[chunk][index] = -1;
  
  
  
  1.22      +3 -3      xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java
  
  Index: SAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SAXParser.java	2001/01/29 05:46:56	1.21
  +++ SAXParser.java	2001/02/01 09:58:19	1.22
  @@ -88,7 +88,7 @@
    * SAXParser provides a parser which implements the SAX1 and SAX2
    * parser APIs.
    *
  - * @version $Id: SAXParser.java,v 1.21 2001/01/29 05:46:56 andyc Exp $
  + * @version $Id: SAXParser.java,v 1.22 2001/02/01 09:58:19 andyc Exp $
    */
   public class SAXParser
       extends XMLParser
  @@ -1342,7 +1342,7 @@
           if (fContentHandler != null) {
               boolean namespaces = getNamespaces();
               int uriIndex = element.uri;
  -            String uri = uriIndex != -1 && namespaces
  +            String uri = uriIndex != StringPool.EMPTY_STRING && namespaces
                          ? fStringPool.toString(uriIndex) : "";
               int localIndex = element.localpart;
               String local = localIndex != -1 && namespaces
  @@ -1394,7 +1394,7 @@
           if (fContentHandler != null) {
               boolean namespaces = getNamespaces();
               int uriIndex = element.uri;
  -            String uri = uriIndex != -1 && namespaces
  +            String uri = uriIndex != StringPool.EMPTY_STRING && namespaces
                          ? fStringPool.toString(uriIndex) : "";
               int localIndex = element.localpart;
               String local = localIndex != -1 && namespaces
  
  
  
  1.9       +2 -2      xml-xerces/java/src/org/apache/xerces/readers/AbstractCharReader.java
  
  Index: AbstractCharReader.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/readers/AbstractCharReader.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractCharReader.java	2000/09/29 07:22:07	1.8
  +++ AbstractCharReader.java	2001/02/01 09:58:21	1.9
  @@ -75,7 +75,7 @@
    * a character stream (java.io.Reader).  The UTF8CharReader performs
    * its own UTF-8 transcoding to fill in the data from an InputStream.
    *
  - * @version $Id: AbstractCharReader.java,v 1.8 2000/09/29 07:22:07 jeffreyr Exp $
  + * @version $Id: AbstractCharReader.java,v 1.9 2001/02/01 09:58:21 andyc Exp $
    */
   abstract class AbstractCharReader extends XMLEntityReader {
   
  @@ -874,7 +874,7 @@
           qname.rawname = fCurrentChunk.addSymbol(offset, length, hashcode);
           qname.prefix = prefixend == -1 ? -1 : addSymbol(offset, prefixend - offset);
           qname.localpart = prefixend == -1 ? qname.rawname : addSymbol(prefixend + 1, fCurrentOffset - (prefixend + 1));
  -        qname.uri = -1;
  +        qname.uri = StringPool.EMPTY_STRING;
   
       } // scanQName(char,QName)
   
  
  
  
  1.5       +2 -2      xml-xerces/java/src/org/apache/xerces/readers/StreamingCharReader.java
  
  Index: StreamingCharReader.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/readers/StreamingCharReader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StreamingCharReader.java	2000/05/17 18:32:40	1.4
  +++ StreamingCharReader.java	2001/02/01 09:58:22	1.5
  @@ -72,7 +72,7 @@
    * An reader class for applications that need to process input data as 
    * it arrives on the stream.
    * 
  - * @version $Id: StreamingCharReader.java,v 1.4 2000/05/17 18:32:40 jeffreyr Exp $
  + * @version $Id: StreamingCharReader.java,v 1.5 2001/02/01 09:58:22 andyc Exp $
    */
   public class StreamingCharReader extends XMLEntityReader {
   
  @@ -781,7 +781,7 @@
           qname.rawname = fCurrentChunk.addSymbol(offset, length, hashcode);
           qname.prefix = prefixend == -1 ? -1 : addSymbol(offset, prefixend - offset);
           qname.localpart = prefixend == -1 ? qname.rawname : addSymbol(prefixend + 1, fCurrentOffset - (prefixend + 1));
  -        qname.uri = -1;
  +        qname.uri = StringPool.EMPTY_STRING;
   
       } // scanQName(char,QName)
   
  
  
  
  1.6       +2 -2      xml-xerces/java/src/org/apache/xerces/readers/UCSReader.java
  
  Index: UCSReader.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/readers/UCSReader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UCSReader.java	2000/12/14 18:47:09	1.5
  +++ UCSReader.java	2001/02/01 09:58:23	1.6
  @@ -75,7 +75,7 @@
    * could take advantage of the system design to improve performance and reduce
    * resource consumption, but the actual performance tuning remains to be done.
    *
  - * @version $Id: UCSReader.java,v 1.5 2000/12/14 18:47:09 lehors Exp $
  + * @version $Id: UCSReader.java,v 1.6 2001/02/01 09:58:23 andyc Exp $
    */
   final class UCSReader extends XMLEntityReader implements StringPool.StringProducer {
   
  @@ -745,7 +745,7 @@
           qname.prefix = prefixend == -1 ? -1 : addSymbol(offset, prefixend - offset);
           qname.rawname = addSymbol(offset, length);
           qname.localpart = prefixend == -1 ? qname.rawname : addSymbol(prefixend + fBytesPerChar, fCurrentOffset - (prefixend + fBytesPerChar));
  -        qname.uri = -1;
  +        qname.uri = StringPool.EMPTY_STRING;
   
   
   
  
  
  
  1.12      +2 -2      xml-xerces/java/src/org/apache/xerces/readers/UTF8Reader.java
  
  Index: UTF8Reader.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/readers/UTF8Reader.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- UTF8Reader.java	2000/11/09 21:51:36	1.11
  +++ UTF8Reader.java	2001/02/01 09:58:23	1.12
  @@ -88,7 +88,7 @@
    * the SUN java runtime compiler (JIT) and the code here has been
    * carefully "crafted" to avoid those problems.
    * 
  - * @version $Id: UTF8Reader.java,v 1.11 2000/11/09 21:51:36 jeffreyr Exp $
  + * @version $Id: UTF8Reader.java,v 1.12 2001/02/01 09:58:23 andyc Exp $
    */
   final class UTF8Reader extends XMLEntityReader {
       //
  @@ -1406,7 +1406,7 @@
           qname.rawname = addSymbol(offset, length);
           qname.prefix = prefixend == -1 ? -1 : addSymbol(offset, prefixend - offset);
           qname.localpart = prefixend == -1 ? qname.rawname : addSymbol(prefixend + 1, fCurrentOffset - (prefixend + 1));
  -        qname.uri = -1;
  +        qname.uri = StringPool.EMPTY_STRING;
   
       } // scanQName(char,QName)
   
  
  
  
  1.3       +1 -1      xml-xerces/java/src/org/apache/xerces/utils/NamespacesScope.java
  
  Index: NamespacesScope.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/utils/NamespacesScope.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NamespacesScope.java	2001/01/25 07:18:40	1.2
  +++ NamespacesScope.java	2001/02/01 09:58:27	1.3
  @@ -129,7 +129,7 @@
                   }
               }
           }
  -        return -1;
  +        return StringPool.EMPTY_STRING;
       }
       /**
        *  Add a new namespace mapping
  
  
  
  1.3       +55 -7     xml-xerces/java/src/org/apache/xerces/utils/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/utils/QName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QName.java	2000/05/17 18:32:51	1.2
  +++ QName.java	2001/02/01 09:58:28	1.3
  @@ -61,11 +61,21 @@
    * QName structure useful for gathering the parts of a qualified name.
    *
    * @author Andy Clark
  - * @version $Id: QName.java,v 1.2 2000/05/17 18:32:51 jeffreyr Exp $
  + * @version $Id: QName.java,v 1.3 2001/02/01 09:58:28 andyc Exp $
    */
   public class QName {
   
       //
  +    // Constants
  +    //
  +
  +    /** 
  +     * Compile to true to help find places where a URI is being set
  +     * to the value -1 when it should be StringPool.EMPTY_STRING (0).
  +     */
  +    private static final boolean FIND_URI_IS_MINUS_ONE = false;
  +
  +    //
       // Data
       //
   
  @@ -92,7 +102,7 @@
   
       /** Constructs a specified qname. */
       public QName(int prefix, int localpart, int rawname) {
  -        setValues(prefix, localpart, rawname, -1);
  +        setValues(prefix, localpart, rawname, StringPool.EMPTY_STRING);
       }
   
       /** Constructs a specified qname. */
  @@ -111,6 +121,16 @@
   
       /** Sets the values of the qualified name. */
       public void setValues(QName qname) {
  +        if (FIND_URI_IS_MINUS_ONE) {
  +            if (qname.uri == -1) {
  +                try { 
  +                    throw new Exception("uri value is -1 instead of StringPool.EMPTY_STRING (0)"); 
  +                }
  +                catch (Exception e) { 
  +                    e.printStackTrace(System.err); 
  +                }
  +            }
  +        }
           prefix = qname.prefix;
           localpart = qname.localpart;
           rawname = qname.rawname;
  @@ -119,11 +139,21 @@
   
       /** Sets the values of the qualified name. */
       public void setValues(int prefix, int localpart, int rawname) {
  -        setValues(prefix, localpart, rawname, -1);
  +        setValues(prefix, localpart, rawname, StringPool.EMPTY_STRING);
       }
   
       /** Sets the values of the qualified name. */
       public void setValues(int prefix, int localpart, int rawname, int uri) {
  +        if (FIND_URI_IS_MINUS_ONE) {
  +            if (uri == -1) {
  +                try { 
  +                    throw new Exception("uri value is -1 instead of StringPool.EMPTY_STRING (0)"); 
  +                }
  +                catch (Exception e) { 
  +                    e.printStackTrace(System.err); 
  +                }
  +            }
  +        }
           this.prefix = prefix;
           this.localpart = localpart;
           this.rawname = rawname;
  @@ -135,7 +165,7 @@
           prefix = -1;
           localpart = -1;
           rawname = -1;
  -        uri = -1;
  +        uri = StringPool.EMPTY_STRING;
       }
   
       //
  @@ -146,9 +176,10 @@
       public boolean equals(Object object) {
           if (object != null && object instanceof QName) {
               QName qname = (QName)object;
  -            return prefix == qname.prefix &&
  -                   localpart == qname.localpart &&
  -                   rawname == qname.rawname &&
  +            if (uri == StringPool.EMPTY_STRING) {
  +                return rawname == qname.rawname;
  +            }
  +            return localpart == qname.localpart &&
                      uri == qname.uri;
           }
           return false;
  @@ -173,6 +204,23 @@
           str.append(", ");
           str.append("uri: ");
           str.append(uri);
  +        return str.toString();
  +    }
  +
  +    /** Returns a string representation of this object. */
  +    public String toString(StringPool stringPool) {
  +        StringBuffer str = new StringBuffer();
  +        str.append("prefix: ");
  +        str.append(String.valueOf(stringPool.toString(prefix)));
  +        str.append(", ");
  +        str.append("localpart: ");
  +        str.append(String.valueOf(stringPool.toString(localpart)));
  +        str.append(", ");
  +        str.append("rawname: ");
  +        str.append(String.valueOf(stringPool.toString(rawname)));
  +        str.append(", ");
  +        str.append("uri: ");
  +        str.append(String.valueOf(stringPool.toString(uri)));
           return str.toString();
       }
   
  
  
  
  1.22      +6 -6      xml-xerces/java/src/org/apache/xerces/validators/common/DFAContentModel.java
  
  Index: DFAContentModel.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/DFAContentModel.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DFAContentModel.java	2001/01/29 09:10:06	1.21
  +++ DFAContentModel.java	2001/02/01 09:58:30	1.22
  @@ -61,7 +61,7 @@
   import org.apache.xerces.utils.ImplementationMessages;
   import org.apache.xerces.utils.QName;
   import org.apache.xerces.validators.schema.SubstitutionGroupComparator;
  -//import org.apache.xerces.utils.StringPool;
  +import org.apache.xerces.utils.StringPool;
   
   /**
    * DFAContentModel is the derivative of ContentModel that does
  @@ -75,7 +75,7 @@
    * are very constrained in form and easily handled via a special case. 
    * This also makes implementation of this class much easier.
    *
  - * @version $Id: DFAContentModel.java,v 1.21 2001/01/29 09:10:06 andyc Exp $
  + * @version $Id: DFAContentModel.java,v 1.22 2001/02/01 09:58:30 andyc Exp $
    */
   public class DFAContentModel 
       implements XMLContentModel {
  @@ -412,14 +412,14 @@
                       }
                       else if (type == XMLContentSpec.CONTENTSPECNODE_ANY) {
                           int uri = fElemMap[elemIndex].uri;
  -                        if (uri == -1 || uri == curElem.uri) {
  +                        if (uri == StringPool.EMPTY_STRING || uri == curElem.uri) {
                               nextState = fTransTable[curState][elemIndex];
                               if (nextState != -1) 
                                 break;
                           }
                       }
                       else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  -                        if (curElem.uri == -1) {
  +                        if (curElem.uri == StringPool.EMPTY_STRING) {
                               nextState = fTransTable[curState][elemIndex];
                               if (nextState != -1) 
                                 break;
  @@ -532,14 +532,14 @@
                   }
                   else if (type == XMLContentSpec.CONTENTSPECNODE_ANY) {
                       int uri = fElemMap[elemIndex].uri;
  -                    if (uri == -1 || uri == curElem.uri) {
  +                    if (uri == StringPool.EMPTY_STRING || uri == curElem.uri) {
                           nextState = fTransTable[curState][elemIndex];
                           if (nextState != -1) 
                             break;
                       }
                   }
                   else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  -                    if (curElem.uri == -1) {
  +                    if (curElem.uri == StringPool.EMPTY_STRING) {
                           nextState = fTransTable[curState][elemIndex];
                           if (nextState != -1) 
                             break;
  
  
  
  1.17      +6 -2      xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java
  
  Index: Grammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/Grammar.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Grammar.java	2001/01/18 07:10:51	1.16
  +++ Grammar.java	2001/02/01 09:58:31	1.17
  @@ -60,6 +60,7 @@
   import org.apache.xerces.framework.XMLContentSpec;
   import org.apache.xerces.utils.Hash2intTable;
   import org.apache.xerces.utils.QName;
  +import org.apache.xerces.utils.StringPool;
   import org.apache.xerces.validators.datatype.DatatypeValidator;
   import org.apache.xerces.validators.common.XMLContentModel;
   import org.apache.xerces.validators.common.CMException;
  @@ -70,7 +71,7 @@
   
   
   /**
  - * @version $Id: Grammar.java,v 1.16 2001/01/18 07:10:51 andyc Exp $
  + * @version $Id: Grammar.java,v 1.17 2001/02/01 09:58:31 andyc Exp $
    */
   public class Grammar
   implements XMLContentSpec.Provider {
  @@ -79,6 +80,9 @@
       // Constants
       //
   
  +    /** Signifies top level scope (-1). */
  +    public static final int TOP_LEVEL_SCOPE = -1;
  +
       private static final int CHUNK_SHIFT = 8; // 2^8 = 256
       private static final int CHUNK_SIZE = (1 << CHUNK_SHIFT);
       private static final int CHUNK_MASK = CHUNK_SIZE - 1;
  @@ -148,7 +152,7 @@
   
       public int getElementDeclIndex(int localpartIndex, int scopeIndex) {
           if ( localpartIndex > -1 && scopeIndex >-2 ) {
  -            return fElementNameAndScopeToElementDeclIndexMapping.get(-1, localpartIndex, scopeIndex);
  +            return fElementNameAndScopeToElementDeclIndexMapping.get(StringPool.EMPTY_STRING, localpartIndex, scopeIndex);
           }
           return -1;
       }
  
  
  
  1.10      +6 -5      xml-xerces/java/src/org/apache/xerces/validators/common/MixedContentModel.java
  
  Index: MixedContentModel.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/MixedContentModel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MixedContentModel.java	2001/01/19 17:07:35	1.9
  +++ MixedContentModel.java	2001/02/01 09:58:32	1.10
  @@ -59,6 +59,7 @@
   
   import org.apache.xerces.framework.XMLContentSpec;
   import org.apache.xerces.utils.QName;
  +import org.apache.xerces.utils.StringPool;
   import org.apache.xerces.validators.schema.SubstitutionGroupComparator;
   
   /**
  @@ -74,7 +75,7 @@
    * validate by just looking up each child being validated by looking it up
    * in the list.
    *
  - * @version $Id: MixedContentModel.java,v 1.9 2001/01/19 17:07:35 neilg Exp $
  + * @version $Id: MixedContentModel.java,v 1.10 2001/02/01 09:58:32 andyc Exp $
    */
   public class MixedContentModel 
       implements XMLContentModel {
  @@ -227,12 +228,12 @@
                   }
                   else if (type == XMLContentSpec.CONTENTSPECNODE_ANY) {
                       int uri = fChildren[inIndex].uri;
  -                    if (uri != -1 && uri != children[outIndex].uri) {
  +                    if (uri != StringPool.EMPTY_STRING && uri != children[outIndex].uri) {
                           return outIndex;
                       }
                   }
                   else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  -                    if (children[outIndex].uri != -1) {
  +                    if (children[outIndex].uri != StringPool.EMPTY_STRING) {
                           return outIndex;
                       }
                   }
  @@ -277,12 +278,12 @@
                       }
                       else if (type == XMLContentSpec.CONTENTSPECNODE_ANY) {
                           int uri = fChildren[inIndex].uri;
  -                        if (uri == -1 || uri == children[outIndex].uri) {
  +                        if (uri == StringPool.EMPTY_STRING || uri == children[outIndex].uri) {
                               break;
                           }
                       }
                       else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  -                        if (children[outIndex].uri == -1) {
  +                        if (children[outIndex].uri == StringPool.EMPTY_STRING) {
                               break;
                           }
                       }
  
  
  
  1.111     +19 -15    xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java
  
  Index: XMLValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/common/XMLValidator.java,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- XMLValidator.java	2001/01/29 08:03:22	1.110
  +++ XMLValidator.java	2001/02/01 09:58:32	1.111
  @@ -121,7 +121,7 @@
   /**
    * This class is the super all-in-one validator used by the parser.
    *
  - * @version $Id: XMLValidator.java,v 1.110 2001/01/29 08:03:22 andyc Exp $
  + * @version $Id: XMLValidator.java,v 1.111 2001/02/01 09:58:32 andyc Exp $
    */
   public final class XMLValidator
       implements DefaultEntityHandler.EventHandler,
  @@ -2104,7 +2104,7 @@
                  if (fTempAttDecl.type == XMLAttributeDecl.TYPE_ANY_ANY) {
                     return attDefIndex;
                  } else if (fTempAttDecl.type == XMLAttributeDecl.TYPE_ANY_LOCAL) {
  -                  if (attribute.uri == -1) {
  +                  if (attribute.uri == StringPool.EMPTY_STRING) {
                        return attDefIndex;
                     }
                  } else if (fTempAttDecl.type == XMLAttributeDecl.TYPE_ANY_OTHER) {
  @@ -2343,9 +2343,9 @@
         // bind element to URI
         int prefix = element.prefix != -1 ? element.prefix : 0;
         int uri    = fNamespacesScope.getNamespaceForPrefix(prefix);
  -      if (element.prefix != -1 || uri != -1) {
  +      if (element.prefix != -1 || uri != StringPool.EMPTY_STRING) {
            element.uri = uri;
  -         if (element.uri == -1) {
  +         if (element.uri == StringPool.EMPTY_STRING) {
               Object[] args = { fStringPool.toString(element.prefix)};
               fErrorReporter.reportError(fErrorReporter.getLocator(),
                                          XMLMessages.XMLNS_DOMAIN,
  @@ -2476,6 +2476,7 @@
            	   // entity resolver, and also can fall-back to entityhandler's expandSystemId()
                  tst = new TraverseSchema( root, fStringPool, (SchemaGrammar)grammar, fGrammarResolver, fErrorReporter, source.getSystemId(), currentER);
                  fGrammarResolver.putGrammar(root.getAttribute("targetNamespace"), grammar);
  +               fGrammar = (SchemaGrammar)grammar;
               }
            } catch (Exception e) {
               e.printStackTrace(System.err);
  @@ -2672,11 +2673,11 @@
                     break;
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY) {
                  int uri = fElemMap[i].uri;
  -               if (uri == -1 || uri == element.uri) {
  +               if (uri == StringPool.EMPTY_STRING || uri == element.uri) {
                     break;
                  }
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL) {
  -               if (element.uri == -1) {
  +               if (element.uri == StringPool.EMPTY_STRING) {
                     break;
                  }
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_OTHER) {
  @@ -2685,12 +2686,12 @@
                  }
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_SKIP) {
                  int uri = fElemMap[i].uri;
  -               if (uri == -1 || uri == element.uri) {
  +               if (uri == StringPool.EMPTY_STRING || uri == element.uri) {
                     skipThisOne = true;
                     break;
                  }
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL_SKIP) {
  -               if (element.uri == -1) {
  +               if (element.uri == StringPool.EMPTY_STRING) {
                     skipThisOne = true;
                     break;
                  }
  @@ -2701,12 +2702,12 @@
                  }
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LAX) {
                  int uri = fElemMap[i].uri;
  -               if (uri == -1 || uri == element.uri) {
  +               if (uri == StringPool.EMPTY_STRING || uri == element.uri) {
                     laxThisOne = true;
                     break;
                  }
               } else if (type == XMLContentSpec.CONTENTSPECNODE_ANY_LOCAL_LAX) {
  -               if (element.uri == -1) {
  +               if (element.uri == StringPool.EMPTY_STRING) {
                     laxThisOne = true;
                     break;
                  }
  @@ -2727,7 +2728,9 @@
   
            //REVISIT: is this the right place to check on if the Schema has changed?
   
  -         if ( fNamespacesEnabled && fValidating && element.uri != fGrammarNameSpaceIndex && element.uri != -1  ) {
  +         if ( fNamespacesEnabled && fValidating && 
  +              element.uri != fGrammarNameSpaceIndex && 
  +              element.uri != StringPool.EMPTY_STRING) {
               fGrammarNameSpaceIndex = element.uri;
   
               boolean success = switchGrammar(fGrammarNameSpaceIndex);
  @@ -2838,10 +2841,10 @@
                  }
   
                  String uri = "";
  -               int uriIndex = -1;
  +               int uriIndex = StringPool.EMPTY_STRING;
                  if (fNamespacesScope != null) {
                     uriIndex = fNamespacesScope.getNamespaceForPrefix(fStringPool.addSymbol(prefix));
  -                  if (uriIndex > -1) {
  +                  if (uriIndex > 0) {
                        uri = fStringPool.toString(uriIndex);
                        if (uriIndex != fGrammarNameSpaceIndex) {
                           fGrammarNameSpaceIndex = fCurrentSchemaURI = uriIndex;
  @@ -3027,7 +3030,7 @@
                                       boolean processContentStrict = 
                                       fTempAttDecl.defaultType == XMLAttributeDecl.PROCESSCONTENTS_STRICT;
   
  -                                    if (fTempQName.uri == -1) {
  +                                    if (fTempQName.uri == StringPool.EMPTY_STRING) {
                                          if (processContentStrict) {
                                             reportError = true;
                                          }
  @@ -3153,7 +3156,7 @@
                  if (attPrefix != fNamespacesPrefix) {
                     if (attPrefix != -1) {
                        int uri = fNamespacesScope.getNamespaceForPrefix(attPrefix);
  -                     if (uri == -1) {
  +                     if (uri == StringPool.EMPTY_STRING) {
                           Object[] args = { fStringPool.toString(attPrefix)};
                           fErrorReporter.reportError(fErrorReporter.getLocator(),
                                                      XMLMessages.XMLNS_DOMAIN,
  @@ -4135,6 +4138,7 @@
                       //          order because we just take advantage of
                       //          a java.util.Hashtable to keep the mapping
                       //          between fields and their values. -Ac
  +                    // REVISIT: Compare according to the datatype. -Ac
                       if (!valueTuple.contains(value)) {
                           continue LOOP;
                       }
  
  
  
  1.9       +6 -6      xml-xerces/java/src/org/apache/xerces/validators/dtd/DTDGrammar.java
  
  Index: DTDGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/dtd/DTDGrammar.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DTDGrammar.java	2000/11/04 00:13:18	1.8
  +++ DTDGrammar.java	2001/02/01 09:58:36	1.9
  @@ -85,7 +85,7 @@
    * SAX2 DeclHandler callbacks.)
    *
    * @author Andy Clark
  - * @version $Id: DTDGrammar.java,v 1.8 2000/11/04 00:13:18 ericye Exp $
  + * @version $Id: DTDGrammar.java,v 1.9 2001/02/01 09:58:36 andyc Exp $
    */
   public class DTDGrammar
       extends Grammar 
  @@ -236,7 +236,7 @@
           // create doctype decl
           Element doctypeDecl = fGrammarDocument.createElement("doctypeDecl");
           doctypeDecl.setAttribute("name", fStringPool.toString(rootElement.rawname));
  -        if (rootElement.uri != -1) {
  +        if (rootElement.uri != StringPool.EMPTY_STRING) {
               doctypeDecl.setAttribute("xmlns:"+fStringPool.toString(rootElement.prefix),
                                        fStringPool.toString(rootElement.uri));
           }
  @@ -292,7 +292,7 @@
           // create element decl element
           Element elementDeclElement = fGrammarDocument.createElement("elementDecl");
           elementDeclElement.setAttribute("name", fStringPool.toString(elementDecl.localpart));
  -        if (elementDecl.uri != -1) {
  +        if (elementDecl.uri != StringPool.EMPTY_STRING) {
               elementDeclElement.setAttribute("xmlns:"+fStringPool.toString(elementDecl.prefix),
                                               fStringPool.toString(elementDecl.uri));
           }
  @@ -328,7 +328,7 @@
           // create element decl element
           Element elementDeclElement = fGrammarDocument.createElement("elementDecl");
           elementDeclElement.setAttribute("name", fStringPool.toString(elementDecl.localpart));
  -        if (elementDecl.uri != -1) {
  +        if (elementDecl.uri != StringPool.EMPTY_STRING) {
               elementDeclElement.setAttribute("xmlns:"+fStringPool.toString(elementDecl.prefix),
                                               fStringPool.toString(elementDecl.uri));
           }
  @@ -359,7 +359,7 @@
   
       protected void putElementNameMapping(QName name, int scope,
                                            int elementDeclIndex) {
  -        fQName.uri = -1;
  +        fQName.uri = StringPool.EMPTY_STRING;
           fQName.localpart = name.rawname;
           super.putElementNameMapping(fQName, scope, elementDeclIndex);
       }
  @@ -455,7 +455,7 @@
           Element attributeDeclElement = fGrammarDocument.createElement("attributeDecl");
           attributeDeclElement.setAttribute("element", fStringPool.toString(elementDecl.localpart));
           attributeDeclElement.setAttribute("name", fStringPool.toString(attributeDecl.localpart));
  -        if (attributeDecl.uri != -1) {
  +        if (attributeDecl.uri != StringPool.EMPTY_STRING) {
               attributeDeclElement.setAttribute("xmlns:"+fStringPool.toString(attributeDecl.prefix),
                                                 fStringPool.toString(attributeDecl.uri));
           }
  
  
  
  1.15      +1 -2      xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaGrammar.java
  
  Index: SchemaGrammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/SchemaGrammar.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SchemaGrammar.java	2001/01/19 17:07:37	1.14
  +++ SchemaGrammar.java	2001/02/01 09:58:39	1.15
  @@ -60,7 +60,7 @@
    * @author Eric Ye
    *         
    * @see    
  - * @version $Id: SchemaGrammar.java,v 1.14 2001/01/19 17:07:37 neilg Exp $
  + * @version $Id: SchemaGrammar.java,v 1.15 2001/02/01 09:58:39 andyc Exp $
    */
   package org.apache.xerces.validators.schema;
   
  @@ -442,7 +442,6 @@
           int attDefIndex = getFirstAttributeDeclIndex(elementIndex);
           while (attDefIndex != -1) {
               getAttributeDecl(attDefIndex, fTempAttributeDecl);
  -
               if (fTempAttributeDecl.name.localpart == attribute.localpart &&
                   fTempAttributeDecl.name.uri == attribute.uri ) {
                   return attDefIndex;
  
  
  
  1.91      +1129 -40  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.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- TraverseSchema.java	2001/01/31 19:49:12	1.90
  +++ TraverseSchema.java	2001/02/01 09:58:40	1.91
  @@ -70,6 +70,7 @@
   import  org.apache.xerces.validators.schema.identity.KeyRef;
   import  org.apache.xerces.validators.schema.identity.Selector;
   import  org.apache.xerces.validators.schema.identity.Unique;
  +import  org.apache.xerces.validators.schema.identity.XPath;
   import  org.apache.xerces.validators.schema.identity.XPathException;
   import  org.apache.xerces.validators.datatype.DatatypeValidator;
   import  org.apache.xerces.validators.datatype.DatatypeValidatorFactoryImpl;
  @@ -120,7 +121,7 @@
    *  
    * @see org.apache.xerces.validators.common.Grammar
    *
  - * @version $Id: TraverseSchema.java,v 1.90 2001/01/31 19:49:12 lmartin Exp $
  + * @version $Id: TraverseSchema.java,v 1.91 2001/02/01 09:58:40 andyc Exp $
    */
   public class TraverseSchema implements 
                               NamespacesScope.NamespacesHandler{
  @@ -141,6 +142,12 @@
       /** Compile to true to debug identity constraints. */
       private static boolean DEBUG_IDENTITY_CONSTRAINTS = false;
       
  +    /** 
  +     * Compile to true to debug datatype validator lookup for
  +     * identity constraint support.
  +     */
  +    private static boolean DEBUG_IC_DATATYPES = false;
  +
   	//CR Implementation
   	private static boolean DEBUG_UNION = false;
   	private static boolean CR_IMPL = true;
  @@ -184,6 +191,8 @@
   
       private EntityResolver  fEntityResolver = null;
       
  +    private Hashtable fIdentityConstraints = new Hashtable();
  +    
      // REVISIT: maybe need to be moved into SchemaGrammar class
       public class ComplexTypeInfo {
           public String typeName;
  @@ -426,6 +435,20 @@
               }
           } // for each child node
   
  +        // handle identity constraints
  +        Enumeration elementIndexes = fIdentityConstraints.keys();
  +        while (elementIndexes.hasMoreElements()) {
  +            Integer elementIndexObj = (Integer)elementIndexes.nextElement();
  +            if (DEBUG_IC_DATATYPES) {
  +                System.out.println("<ICD>: traversing identity constraints for element: "+elementIndexObj);
  +            }
  +            Vector identityConstraints = (Vector)fIdentityConstraints.get(elementIndexObj);
  +            if (identityConstraints != null) {
  +                int elementIndex = elementIndexObj.intValue();
  +                traverseIdentityConstraintsFor(elementIndex, identityConstraints);
  +            }
  +        }
  +
       } // traverseSchema(Element)
   
       private void checkTopLevelDuplicateNames(Element root) {
  @@ -1052,24 +1075,19 @@
               int numEnumerationLiterals = 0;
               facetData        = new Hashtable();
               Vector enumData  = new Vector();
  -            content = checkContent(simpleTypeDecl, content , true);
               while (content != null) { 
                   if (content.getNodeType() == Node.ELEMENT_NODE) {
  -                        numFacets++;
  -                        if (content.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION)) {
  +                    numFacets++;
  +                    if (content.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION)) {
                               numEnumerationLiterals++;
                               String enumVal = content.getAttribute(SchemaSymbols.ATT_VALUE);
                               enumData.addElement(enumVal);
  +                            //Enumerations can have annotations ? ( 0 | 1 )
                               checkContent(simpleTypeDecl, XUtil.getFirstChildElement( content ), true);
  -                        }
  -                        else if (content.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION)) {
  -                                  reportSchemaError(SchemaMessageProvider.ContentError,
  -                                                    new Object [] { simpleTypeDecl.getAttribute( SchemaSymbols.ATT_NAME )});
  -                        }
  -                        else {
  -                             facetData.put(content.getLocalName(),content.getAttribute( SchemaSymbols.ATT_VALUE ));
  -                             checkContent(simpleTypeDecl, XUtil.getFirstChildElement( content ), true);
  -                        }
  +                    }
  +                    else {
  +                         facetData.put(content.getLocalName(),content.getAttribute( SchemaSymbols.ATT_VALUE ));
  +                    }
                   }
                       content = XUtil.getNextSiblingElement(content);
               }
  @@ -1164,6 +1182,8 @@
           }
   
           if (namespace.length() == 0 || namespace.equals("##any")) {
  +            // REVISIT: Should the "any" namespace signifier also be changed
  +            //          to StringPool.EMPTY_STRING instead of -1? -Ac
               anyIndex = fSchemaGrammar.addContentSpecNode(processContentsAny, -1, -1, false);
           }
           else if (namespace.equals("##other")) {
  @@ -1413,6 +1433,714 @@
       }
   
       /**
  +     * Traverse ComplexType Declaration.
  +     *  
  +     *       <complexType 
  +     *         abstract = boolean 
  +     *         base = QName 
  +     *         block = #all or (possibly empty) subset of {extension, restriction} 
  +     *         content = elementOnly | empty | mixed | textOnly 
  +     *         derivedBy = extension | restriction 
  +     *         final = #all or (possibly empty) subset of {extension, restriction} 
  +     *         id = ID 
  +     *         name = NCName>
  +     *          Content: (annotation? , (((minExclusive | minInclusive | maxExclusive
  +     *                    | maxInclusive | precision | scale | length | minLength 
  +     *                    | maxLength | encoding | period | duration | enumeration 
  +     *                    | pattern)* | (element | group | all | choice | sequence | any)*) , 
  +     *                    ((attribute | attributeGroup)* , anyAttribute?)))
  +     *        </complexType>
  +     * @param complexTypeDecl
  +     * @return 
  +     */
  +    
  +    //REVISIT: TO DO, base and derivation ???
  +    private int traverseComplexTypeDecl( Element complexTypeDecl ) throws Exception { 
  +        String isAbstract = complexTypeDecl.getAttribute( SchemaSymbols.ATT_ABSTRACT );
  +        String base = complexTypeDecl.getAttribute(SchemaSymbols.ATT_BASE);
  +        String blockSet = complexTypeDecl.getAttribute( SchemaSymbols.ATT_BLOCK );
  +        String content = complexTypeDecl.getAttribute(SchemaSymbols.ATT_CONTENT);
  +        String derivedBy = complexTypeDecl.getAttribute( SchemaSymbols.ATT_DERIVEDBY );
  +        String finalSet = complexTypeDecl.getAttribute( SchemaSymbols.ATT_FINAL );
  +        String typeId = complexTypeDecl.getAttribute( SchemaSymbols.ATTVAL_ID );
  +        String typeName = complexTypeDecl.getAttribute(SchemaSymbols.ATT_NAME); 
  +        boolean isNamedType = false;
  +
  +
  +        // traverseComplexTypeDecl supports the April version of the schema spec. 
  +        // For candidate recommendation support, traverseComplexTypeDeclCR must be 
  +        // invoked
  +
  +        if (CR_IMPL) 
  +          return traverseComplexTypeDeclCR(complexTypeDecl);
  +
  +        if ( DEBUGGING )
  +            System.out.println("traversing complex Type : " + typeName +","+base+","+content+".");
  +
  +        if (typeName.equals("")) { // gensym a unique name
  +            //typeName = "http://www.apache.org/xml/xerces/internalType"+fTypeCount++;
  +            typeName = "#"+fAnonTypeCount++;
  +        }
  +        else {
  +            fCurrentTypeNameStack.push(typeName);
  +            isNamedType = true;
  +        }
  +
  +        if (isTopLevel(complexTypeDecl)) {
  +        
  +            String fullName = fTargetNSURIString+","+typeName;
  +            ComplexTypeInfo temp = (ComplexTypeInfo) fComplexTypeRegistry.get(fullName);
  +            if (temp != null ) {
  +                return fStringPool.addSymbol(fullName);
  +            }
  +        }
  +
  +        int scopeDefined = fScopeCount++;
  +        int previousScope = fCurrentScope;
  +        fCurrentScope = scopeDefined;
  +
  +        Element child = null;
  +        int contentSpecType = -1;
  +        int csnType = 0;
  +        int left = -2;
  +        int right = -2;
  +
  +        ComplexTypeInfo baseTypeInfo = null;  //if base is a complexType;
  +        DatatypeValidator baseTypeValidator = null; //if base is a simple type or a complex type derived from a simpleType
  +        DatatypeValidator simpleTypeValidator = null;
  +        int baseTypeSymbol = -1;
  +        String fullBaseName = "";
  +
  +        boolean baseIsSimpleSimple = false;
  +        boolean baseIsComplexSimple = false;
  +        boolean baseFromAnotherSchema = false;
  +        String baseTypeSchemaURI = null;
  +        boolean derivedByRestriction = true;
  +        boolean derivedByExtension = false;
  +        int baseContentSpecHandle = -1;
  +        Element baseTypeNode = null;
  +
  +
  +        //int parsedderivedBy = parseComplexDerivedBy(derivedBy);
  +        //handle the inhreitance here. 
  +        if (base.length()>0) {
  +
  +            //first check if derivedBy is present
  +            if (derivedBy.length() == 0) {
  +                // REVISIT: Localize
  +                reportGenericSchemaError("derivedBy must be present when base is present in " 
  +                                         +SchemaSymbols.ELT_COMPLEXTYPE
  +                                         +" "+ typeName);
  +                derivedBy = SchemaSymbols.ATTVAL_EXTENSION;
  +            }
  +
  +            if (derivedBy.equals(SchemaSymbols.ATTVAL_EXTENSION)) {
  +                derivedByRestriction = false;
  +            }
  +
  +            String prefix = "";
  +            String localpart = base;
  +            int colonptr = base.indexOf(":");
  +            if ( colonptr > 0) {
  +                prefix = base.substring(0,colonptr);
  +                localpart = base.substring(colonptr+1);
  +            }
  +            int localpartIndex = fStringPool.addSymbol(localpart);
  +            String typeURI = resolvePrefixToURI(prefix);
  +
  +            // check if the base type is from the same Schema;
  +            if ( ! typeURI.equals(fTargetNSURIString) 
  +                 && ! typeURI.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) 
  +                 && typeURI.length() != 0 )  /*REVISIT, !!!! a hack: for schema that has no target namespace, e.g. personal-schema.xml*/{
  +                baseFromAnotherSchema = true;
  +                baseTypeSchemaURI = typeURI;
  +                baseTypeInfo = getTypeInfoFromNS(typeURI, localpart);
  +                if (baseTypeInfo == null) {
  +                    baseTypeValidator = getTypeValidatorFromNS(typeURI, localpart);
  +                    if (baseTypeValidator == null) {
  +                        //TO DO: report error here;
  +                        System.out.println("Could not find base type " +localpart 
  +                                           + " in schema " + typeURI);
  +                    }
  +                    else{
  +                        baseIsSimpleSimple = true;
  +                    }
  +                }
  +            }
  +            else {
  +
  +                fullBaseName = typeURI+","+localpart;
  +
  +                // assume the base is a complexType and try to locate the base type first
  +                baseTypeInfo = (ComplexTypeInfo) fComplexTypeRegistry.get(fullBaseName);
  +
  +                // if not found, 2 possibilities: 1: ComplexType in question has not been compiled yet;
  +                //                                2: base is SimpleTYpe;
  +                if (baseTypeInfo == null) {
  +                    baseTypeValidator = getDatatypeValidator(typeURI, localpart);
  +
  +                    if (baseTypeValidator == null) {
  +                        baseTypeNode = getTopLevelComponentByName(SchemaSymbols.ELT_COMPLEXTYPE,localpart);
  +                        if (baseTypeNode != null) {
  +                            baseTypeSymbol = traverseComplexTypeDecl( baseTypeNode );
  +                            baseTypeInfo = (ComplexTypeInfo)
  +                            fComplexTypeRegistry.get(fStringPool.toString(baseTypeSymbol)); //REVISIT: should it be fullBaseName;
  +                        }
  +                        else {
  +                            baseTypeNode = getTopLevelComponentByName(SchemaSymbols.ELT_SIMPLETYPE, localpart);
  +                            if (baseTypeNode != null) {
  +                                    baseTypeSymbol = traverseSimpleTypeDecl( baseTypeNode );
  +                                    simpleTypeValidator = baseTypeValidator = getDatatypeValidator(typeURI, localpart);
  +                                    if (simpleTypeValidator == null) {
  +                                        //TO DO: signal error here.
  +                                    }
  +
  +                                    baseIsSimpleSimple = true;
  +                            }
  +                            else {
  +                                // REVISIT: Localize
  +                                reportGenericSchemaError("Base type could not be found : " + base);
  +                            }
  +                        }
  +                    }
  +                    else {
  +                        simpleTypeValidator = baseTypeValidator;
  +                        baseIsSimpleSimple = true;
  +                    }
  +                }
  +            }
  +            //Schema Spec : 5.11: Complex Type Definition Properties Correct : 2
  +            if (baseIsSimpleSimple && derivedByRestriction) {
  +                // REVISIT: Localize
  +                reportGenericSchemaError("base is a simpledType, can't derive by restriction in " + typeName); 
  +            }
  +
  +            //if  the base is a complexType
  +            if (baseTypeInfo != null ) {
  +
  +                //Schema Spec : 5.11: Derivation Valid ( Extension ) 1.1.1
  +                //              5.11: Derivation Valid ( Restriction, Complex ) 1.2.1
  +                if (derivedByRestriction) {
  +                    //REVISIT: check base Type's finalset does not include "restriction"
  +                }
  +                else {
  +                    //REVISIT: check base Type's finalset doest not include "extension"
  +                }
  +
  +                if ( baseTypeInfo.contentSpecHandle > -1) {
  +                    if (derivedByRestriction) {
  +                        //REVISIT: !!! really hairy staff to check the particle derivation OK in 5.10
  +                        checkParticleDerivationOK(complexTypeDecl, baseTypeNode);
  +                    }
  +                    baseContentSpecHandle = baseTypeInfo.contentSpecHandle;
  +                }
  +                else if ( baseTypeInfo.datatypeValidator != null ) {
  +                    baseTypeValidator = baseTypeInfo.datatypeValidator;
  +                    baseIsComplexSimple = true;
  +                }
  +            }
  +
  +            //Schema Spec : 5.11: Derivation Valid ( Extension ) 1.1.1
  +            if (baseIsComplexSimple && !derivedByRestriction ) {
  +                // REVISIT: Localize
  +                reportGenericSchemaError("base is ComplexSimple, can't derive by extension in " + typeName);
  +            }
  +
  +
  +        } // END of if (base.length() > 0) {}
  +
  +        // skip refinement and annotations
  +        child = null;
  +
  +        if (baseIsComplexSimple) {
  +
  +            contentSpecType = XMLElementDecl.TYPE_SIMPLE;
  +            
  +            int numEnumerationLiterals = 0;
  +            int numFacets = 0;
  +            Hashtable facetData        = new Hashtable();
  +            Vector enumData            = new Vector();
  +
  +
  +            //REVISIT: there is a better way to do this, 
  +            for (child = XUtil.getFirstChildElement(complexTypeDecl);
  +                 child != null && (child.getLocalName().equals(SchemaSymbols.ELT_MINEXCLUSIVE) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_MININCLUSIVE) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_MAXEXCLUSIVE) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_MAXINCLUSIVE) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_PRECISION) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_SCALE) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_LENGTH) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_MINLENGTH) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_MAXLENGTH) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_ENCODING) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_PERIOD) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_DURATION) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_PATTERN) ||
  +                                   child.getLocalName().equals(SchemaSymbols.ELT_ANNOTATION));
  +                 child = XUtil.getNextSiblingElement(child)) 
  +            {
  +                if ( child.getNodeType() == Node.ELEMENT_NODE ) {
  +                    Element facetElt = (Element) child;
  +                    numFacets++;
  +                    if (facetElt.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION)) {
  +                        numEnumerationLiterals++;
  +                        enumData.addElement(facetElt.getAttribute(SchemaSymbols.ATT_VALUE));
  +                        //Enumerations can have annotations ? ( 0 | 1 )
  +                        Element enumContent =  XUtil.getFirstChildElement( facetElt );
  +                        if( enumContent != null && enumContent.getLocalName().equals( SchemaSymbols.ELT_ANNOTATION ) ){
  +                            traverseAnnotationDecl( child );   
  +                        }
  +                        // TO DO: if Jeff check in new changes to TraverseSimpleType, copy them over
  +                    } else {
  +                        facetData.put(facetElt.getLocalName(),facetElt.getAttribute( SchemaSymbols.ATT_VALUE ));
  +                    }
  +                }
  +            }
  +            if (numEnumerationLiterals > 0) {
  +                facetData.put(SchemaSymbols.ELT_ENUMERATION, enumData);
  +            }
  +
  +            //if (numFacets > 0)
  +            //    baseTypeValidator.setFacets(facetData, derivedBy );
  +            if (numFacets > 0) {
  +                simpleTypeValidator = fDatatypeRegistry.createDatatypeValidator( typeName, baseTypeValidator,
  +                                                           facetData, false ); 
  +            }
  +            else
  +                simpleTypeValidator = baseTypeValidator;
  +
  +            if (child != null) {
  +                // REVISIT: Localize
  +                reportGenericSchemaError("Invalid child '"+child.getLocalName()+"' in complexType : '" + typeName 
  +                                         + "', because it restricts another complexSimpleType");
  +            }
  +        }
  +
  +            // if content = textonly, base is a datatype
  +        if (content.equals(SchemaSymbols.ATTVAL_TEXTONLY)) {
  +            //TO DO
  +            if (base.length() == 0) {
  +                simpleTypeValidator = baseTypeValidator = getDatatypeValidator("", SchemaSymbols.ATTVAL_STRING);
  +            }
  +            else if ( baseTypeValidator == null 
  +                      && baseTypeInfo != null && baseTypeInfo.datatypeValidator==null ) // must be datatype
  +                        reportSchemaError(SchemaMessageProvider.NotADatatype,
  +                                          new Object [] { base }); //REVISIT check forward refs
  +            //handle datatypes
  +            contentSpecType = XMLElementDecl.TYPE_SIMPLE;
  +            /****
  +            left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_LEAF,
  +                                                 fStringPool.addSymbol(base),
  +                                                 -1, false);
  +            /****/                                                 
  +
  +        } 
  +        else {   
  +            if (!baseIsComplexSimple) {
  +                contentSpecType = XMLElementDecl.TYPE_CHILDREN;
  +            }
  +            csnType = XMLContentSpec.CONTENTSPECNODE_SEQ;
  +            boolean mixedContent = false;
  +            //REVISIT: is the default content " elementOnly"
  +            boolean elementContent = true;
  +            boolean textContent = false;
  +            boolean emptyContent = false;
  +            left = -2;
  +            right = -2;
  +            boolean hadContent = false;
  +
  +            if (content.equals(SchemaSymbols.ATTVAL_EMPTY)) {
  +                contentSpecType = XMLElementDecl.TYPE_EMPTY;
  +                emptyContent = true;
  +                elementContent = false;
  +                left = -1; // no contentSpecNode needed
  +            } else if (content.equals(SchemaSymbols.ATTVAL_MIXED) ) {
  +                contentSpecType = XMLElementDecl.TYPE_MIXED;
  +                mixedContent = true;
  +                elementContent = false;
  +                csnType = XMLContentSpec.CONTENTSPECNODE_CHOICE;
  +            } else if (content.equals(SchemaSymbols.ATTVAL_ELEMENTONLY) || content.equals("")) {
  +                elementContent = true;
  +            } else if (content.equals(SchemaSymbols.ATTVAL_TEXTONLY)) {
  +                textContent = true;
  +                elementContent = false;
  +            }
  +
  +            if (mixedContent) {
  +                // add #PCDATA leaf
  +
  +                left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_LEAF,
  +                                                         -1, // -1 means "#PCDATA" is name
  +                                                         -1, false);
  +                csnType = XMLContentSpec.CONTENTSPECNODE_CHOICE;
  +            }
  +
  +            boolean seeParticle = false;
  +            boolean seeOtherParticle = false;                
  +            boolean seeAll = false;
  +
  +            for (child = XUtil.getFirstChildElement(complexTypeDecl);
  +                 child != null;
  +                 child = XUtil.getNextSiblingElement(child)) {
  +
  +                int index = -2;  // to save the particle's contentSpec handle 
  +                hadContent = true;
  +
  +                seeParticle = false;
  +
  +                String childName = child.getLocalName();
  +
  +                if (childName.equals(SchemaSymbols.ELT_ELEMENT)) {
  +                    if (mixedContent || elementContent) {
  +                        if ( DEBUGGING )
  +                            System.out.println(" child element name " + child.getAttribute(SchemaSymbols.ATT_NAME));
  +
  +                        QName eltQName = traverseElementDecl(child);
  +                        index = fSchemaGrammar.addContentSpecNode( XMLContentSpec.CONTENTSPECNODE_LEAF,
  +                                                                   eltQName.localpart,
  +                                                                   eltQName.uri, 
  +                                                                   false);
  +                        seeParticle = true;
  +                        seeOtherParticle = true;
  +
  +                    } 
  +                    else {
  +                        reportSchemaError(SchemaMessageProvider.EltRefOnlyInMixedElemOnly, null);
  +                    }
  +
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_GROUP)) {
  +                    index = traverseGroupDecl(child);
  +                    if (index == -1) 
  +                        continue;
  +                    seeParticle = true;
  +                    seeOtherParticle = true;
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_ALL)) {
  +                    index = traverseAll(child);
  +                    seeParticle = true;
  +                    seeAll = true;
  +                  
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
  +                    index = traverseChoice(child);
  +                    seeParticle = true;
  +                    seeOtherParticle = true;                  
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
  +                    index = traverseSequence(child);
  +                    seeParticle = true;
  +                    seeOtherParticle = true;                  
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
  +                           childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
  +                    break; // attr processing is done later on in this method
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_ANY)) {
  +
  +                    index = traverseAny(child);
  +                    seeParticle = true;
  +                    seeOtherParticle = true;
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
  +                    //REVISIT, do nothing for annotation for now.
  +                } 
  +                else if (childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE)) {
  +                    break;
  +                    //REVISIT, do nothing for attribute wildcard for now.
  +                } 
  +                else { // datatype qual 
  +                    if (!baseIsComplexSimple ) 
  +                    if (base.equals(""))
  +                        reportSchemaError(SchemaMessageProvider.GenericError, 
  +                                          new Object [] { "unrecognized child '"+childName+"' in complex type "+typeName });
  +                    else
  +                        reportSchemaError(SchemaMessageProvider.GenericError,
  +                                          new Object [] { "unrecognized child '"+childName+"' in complex type '"+typeName+"' with base "+base  });
  +                }
  +
  +                // if base is complextype with simpleType content, can't have any particle children at all.
  +                if (baseIsComplexSimple && seeParticle) {
  +                    // REVISIT: Localize
  +                    reportGenericSchemaError("In complexType "+typeName+", base type is complexType with simpleType content, can't have any particle children at all");
  +                    hadContent = false;
  +                    left = index = -2;
  +                    contentSpecType = XMLElementDecl.TYPE_SIMPLE;
  +                    break;
  +                }
  +
  +
  +                if (seeAll && seeOtherParticle) {
  +                    // REVISIT: Localize
  +                    reportGenericSchemaError ( " 'All' group needs to be the only child in Complextype : " + typeName);
  +                }
  +
  +                if (seeAll) {
  +                    //TO DO: REVISIT 
  +                    //check the minOccurs = 1 and maxOccurs = 1  
  +                }
  +
  +                // check the minOccurs and maxOccurs of the particle, and fix the  
  +                // contentspec accordingly
  +                if (seeParticle) {
  +                    index = expandContentModel(index, child);
  +                    if (index == -2 ) {
  +                        continue;
  +                    }
  +                } //end of if (seeParticle)
  +
  +                if (left == -2) {
  +                    left = index;
  +                } else if (right == -2) {
  +                    right = index;
  +                } else {
  +                    left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
  +                    right = index;
  +                }
  +            } //end looping through the children
  +
  +            if ( ! ( seeOtherParticle || seeAll ) && (elementContent || mixedContent)
  +                 &&  (base.length() == 0 || ( base.length() > 0 && derivedByRestriction && !baseIsComplexSimple))  ) {
  +                contentSpecType = XMLElementDecl.TYPE_SIMPLE;
  +                simpleTypeValidator = getDatatypeValidator("", SchemaSymbols.ATTVAL_STRING);
  +                // REVISIT: Localize
  +                reportGenericSchemaError ( " complexType '"+typeName+"' with a elementOnly or mixed content "
  +                                           +"need to have at least one particle child");
  +            }
  +
  +            if (hadContent && right != -2)
  +                left = fSchemaGrammar.addContentSpecNode(csnType, left, right, false);
  +
  +            if (mixedContent && hadContent) {
  +                // set occurrence count
  +                left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_ZERO_OR_MORE,
  +                                                     left, -1, false);
  +            }
  +        }
  +
  +        // if derived by extension and base complextype has a content model, 
  +        // compose the final content model by concatenating the base and the 
  +        // current in sequence.
  +        if (!derivedByRestriction && baseContentSpecHandle > -1 ) {
  +            if (baseFromAnotherSchema ) {
  +                SchemaGrammar aGrammar = (SchemaGrammar) fGrammarResolver.getGrammar(baseTypeSchemaURI);
  +                baseContentSpecHandle = importContentSpec(aGrammar, baseContentSpecHandle);
  +            }
  +            
  +            if (left == -2) {
  +                left = baseContentSpecHandle;
  +            }
  +            else 
  +                left = fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_SEQ, 
  +                                                         baseContentSpecHandle,
  +                                                         left,
  +                                                         false);
  +        }
  +
  +        // REVISIT: this is when sees a topelevel <complexType name="abc">attrs*</complexType>
  +        if (content.length() == 0 && base.length() == 0 && left == -2) {
  +            contentSpecType = XMLElementDecl.TYPE_ANY;
  +        }
  +
  +        if (content.length() == 0 && simpleTypeValidator == null && left == -2 ) {
  +            if (base.length() > 0 && baseTypeInfo != null 
  +                && baseTypeInfo.contentType == XMLElementDecl.TYPE_EMPTY) {
  +                contentSpecType = XMLElementDecl.TYPE_EMPTY;
  +            }
  +        }
  +
  +
  +        ComplexTypeInfo typeInfo = new ComplexTypeInfo();
  +        typeInfo.baseComplexTypeInfo = baseTypeInfo;
  +        typeInfo.baseDataTypeValidator = baseTypeValidator;
  +        int derivedByInt = -1;
  +        if (derivedBy.length() > 0) {
  +            derivedByInt = parseComplexDerivedBy(derivedBy);
  +        }
  +        typeInfo.derivedBy = derivedByInt;
  +        typeInfo.scopeDefined = scopeDefined; 
  +        typeInfo.contentSpecHandle = left;
  +        typeInfo.contentType = contentSpecType;
  +        typeInfo.datatypeValidator = simpleTypeValidator;
  +        typeInfo.blockSet = parseBlockSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_BLOCK));
  +        typeInfo.finalSet = parseFinalSet(complexTypeDecl.getAttribute(SchemaSymbols.ATT_FINAL));
  +        typeInfo.isAbstract = isAbstract.equals(SchemaSymbols.ATTVAL_TRUE) ? true:false ;
  +
  +        //add a template element to the grammar element decl pool.
  +        int typeNameIndex = fStringPool.addSymbol(typeName);
  +        int templateElementNameIndex = fStringPool.addSymbol("$"+typeName);
  +
  +        typeInfo.templateElementIndex = 
  +            fSchemaGrammar.addElementDecl(new QName(-1, templateElementNameIndex,typeNameIndex,fTargetNSURI),
  +                                          (fTargetNSURI==StringPool.EMPTY_STRING) ? StringPool.EMPTY_STRING : fCurrentScope, scopeDefined,
  +                                            contentSpecType, left, 
  +                                          -1, simpleTypeValidator);
  +        typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);
  +
  +
  +        // (attribute | attrGroupRef)*
  +        XMLAttributeDecl attWildcard = null;
  +        Vector anyAttDecls = new Vector();
  +
  +        for (child = XUtil.getFirstChildElement(complexTypeDecl);
  +             child != null;
  +             child = XUtil.getNextSiblingElement(child)) {
  +
  +            String childName = child.getLocalName();
  +
  +            if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
  +                if ((baseIsComplexSimple||baseIsSimpleSimple) && derivedByRestriction) {
  +                    // REVISIT: Localize
  +                    reportGenericSchemaError("In complexType "+typeName+
  +                                             ", base type has simpleType "+
  +                                             "content and derivation method is"+
  +                                             " 'restriction', can't have any "+
  +                                             "attribute children at all");
  +                    break;
  +                }
  +                traverseAttributeDecl(child, typeInfo, false);
  +            } 
  +            else if ( childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ) { 
  +                if ((baseIsComplexSimple||baseIsSimpleSimple) && derivedByRestriction) {
  +                    // REVISIT: Localize
  +                    reportGenericSchemaError("In complexType "+typeName+", base "+
  +                                             "type has simpleType content and "+
  +                                             "derivation method is 'restriction',"+
  +                                             " can't have any attribute children at all");
  +                    break;
  +                }
  +                traverseAttributeGroupDecl(child,typeInfo,anyAttDecls);
  +            }
  +            else if ( childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE) ) { 
  +                attWildcard = traverseAnyAttribute(child);
  +            }
  +        }
  +
  +        if (attWildcard != null) {
  +            XMLAttributeDecl fromGroup = null;
  +            final int count = anyAttDecls.size();
  +            if ( count > 0) {
  +                fromGroup = (XMLAttributeDecl) anyAttDecls.elementAt(0);
  +                for (int i=1; i<count; i++) {
  +                    fromGroup = mergeTwoAnyAttribute(fromGroup,(XMLAttributeDecl)anyAttDecls.elementAt(i));
  +                }
  +            }
  +            if (fromGroup != null) {
  +                int saveProcessContents = attWildcard.defaultType;
  +                attWildcard = mergeTwoAnyAttribute(attWildcard, fromGroup);
  +                attWildcard.defaultType = saveProcessContents;
  +            }
  +        }
  +        else {
  +            //REVISIT: unclear in the Scheme Structures 4.3.3 what to do in this case
  +        }
  +
  +        // merge in base type's attribute decls
  +        XMLAttributeDecl baseAttWildcard = null;
  +        if (baseTypeInfo != null && baseTypeInfo.attlistHead > -1 ) {
  +            int attDefIndex = baseTypeInfo.attlistHead;
  +            SchemaGrammar aGrammar = fSchemaGrammar;
  +            if (baseFromAnotherSchema) {
  +                aGrammar = (SchemaGrammar) fGrammarResolver.getGrammar(baseTypeSchemaURI);
  +            }
  +            if (aGrammar == null) {
  +                reportGenericSchemaError("In complexType "+typeName+", can NOT find the grammar "+
  +                                         "with targetNamespace" + baseTypeSchemaURI+
  +                                         "for the base type");
  +            }
  +            else
  +            while ( attDefIndex > -1 ) {
  +                fTempAttributeDecl.clear();
  +                aGrammar.getAttributeDecl(attDefIndex, fTempAttributeDecl);
  +                if (fTempAttributeDecl.type == XMLAttributeDecl.TYPE_ANY_ANY 
  +                    ||fTempAttributeDecl.type == XMLAttributeDecl.TYPE_ANY_LIST
  +                    ||fTempAttributeDecl.type == XMLAttributeDecl.TYPE_ANY_LOCAL 
  +                    ||fTempAttributeDecl.type == XMLAttributeDecl.TYPE_ANY_OTHER ) {
  +                    if (attWildcard == null) {
  +                        baseAttWildcard = fTempAttributeDecl;
  +                    }
  +                    attDefIndex = aGrammar.getNextAttributeDeclIndex(attDefIndex);
  +                    continue;
  +                }
  +                // if found a duplicate, if it is derived by restriction. then skip the one from the base type
  +                /**/
  +                int temp = fSchemaGrammar.getAttributeDeclIndex(typeInfo.templateElementIndex, fTempAttributeDecl.name);
  +                if ( temp > -1) {
  +                    if (derivedByRestriction) {
  +                        attDefIndex = fSchemaGrammar.getNextAttributeDeclIndex(attDefIndex);
  +                        continue;
  +                    }
  +                }
  +
  +                /**/
  +                fSchemaGrammar.addAttDef( typeInfo.templateElementIndex, 
  +                                          fTempAttributeDecl.name, fTempAttributeDecl.type, 
  +                                          fTempAttributeDecl.enumeration, fTempAttributeDecl.defaultType, 
  +                                          fTempAttributeDecl.defaultValue, 
  +                                          fTempAttributeDecl.datatypeValidator,
  +                                          fTempAttributeDecl.list);
  +                attDefIndex = aGrammar.getNextAttributeDeclIndex(attDefIndex);
  +            }
  +        }
  +        // att wildcard will inserted after all attributes were processed
  +        if (attWildcard != null) {
  +            if (attWildcard.type != -1) {
  +                fSchemaGrammar.addAttDef( typeInfo.templateElementIndex, 
  +                                          attWildcard.name, attWildcard.type, 
  +                                          attWildcard.enumeration, attWildcard.defaultType, 
  +                                          attWildcard.defaultValue, 
  +                                          attWildcard.datatypeValidator,
  +                                          attWildcard.list);
  +            }
  +            else {
  +                //REVISIT: unclear in Schema spec if should report error here.
  +            }
  +        }
  +        else if (baseAttWildcard != null) {
  +            fSchemaGrammar.addAttDef( typeInfo.templateElementIndex, 
  +                                      baseAttWildcard.name, baseAttWildcard.type, 
  +                                      baseAttWildcard.enumeration, baseAttWildcard.defaultType, 
  +                                      baseAttWildcard.defaultValue, 
  +                                      baseAttWildcard.datatypeValidator,
  +                                      baseAttWildcard.list);
  +        }
  +
  +        typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(typeInfo.templateElementIndex);
  +
  +        if (!typeName.startsWith("#")) {
  +            typeName = fTargetNSURIString + "," + typeName;
  +        }
  +        typeInfo.typeName = new String(typeName);
  +        if ( DEBUGGING )
  +            System.out.println(">>>add complex Type to Registry: " + typeName +
  +                               " baseDTValidator=" + typeInfo.baseDataTypeValidator +
  +                               " baseCTInfo=" + typeInfo.baseComplexTypeInfo + 
  +                               " derivedBy=" + typeInfo.derivedBy + 
  +                               " contentType=" + typeInfo.contentType +
  +                               " contentSpecHandle=" + typeInfo.contentSpecHandle + 
  +                               " datatypeValidator=" + typeInfo.datatypeValidator);
  +
  +        fComplexTypeRegistry.put(typeName,typeInfo);
  +
  +        // before exit the complex type definition, restore the scope, mainly for nested Anonymous Types
  +        fCurrentScope = previousScope;
  +        if (isNamedType) {
  +            fCurrentTypeNameStack.pop();
  +            checkRecursingComplexType();
  +        }
  +
  +        //set template element's typeInfo
  +        fSchemaGrammar.setElementComplexTypeInfo(typeInfo.templateElementIndex, typeInfo);
  +
  +        typeNameIndex = fStringPool.addSymbol(typeName);
  +        return typeNameIndex;
  +
  +
  +    } // end of method: traverseComplexTypeDecl
  +
  +    /**
        * Traverse ComplexType Declaration - CR Implementation.
        *  
        *       <complexType 
  @@ -1430,7 +2158,7 @@
        * @return 
        */
       
  -    private int traverseComplexTypeDecl( Element complexTypeDecl ) throws Exception { 
  +    private int traverseComplexTypeDeclCR( Element complexTypeDecl ) throws Exception { 
           
           // ------------------------------------------------------------------
           // Get the attributes of the type
  @@ -1575,7 +2303,7 @@
           typeNameIndex = fStringPool.addSymbol(typeName);
           return typeNameIndex;
   
  -    } // end traverseComplexTypeDecl
  +    } // end traverseComplexTypeDeclCR
   
         
       /**
  @@ -1842,7 +2570,7 @@
   
           typeInfo.templateElementIndex = fSchemaGrammar.addElementDecl(
                new QName(-1, templateElementNameIndex,typeNameIndex,fTargetNSURI),
  -             (fTargetNSURI==-1) ? -1 : fCurrentScope, typeInfo.scopeDefined,
  +             (fTargetNSURI==StringPool.EMPTY_STRING) ? StringPool.EMPTY_STRING : fCurrentScope, typeInfo.scopeDefined,
                typeInfo.contentType, 
                typeInfo.contentSpecHandle, -1, typeInfo.datatypeValidator);
           typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(
  @@ -2029,7 +2757,7 @@
           int templateElementNameIndex = fStringPool.addSymbol("$"+typeName);
           typeInfo.templateElementIndex = fSchemaGrammar.addElementDecl(
               new QName(-1, templateElementNameIndex,typeNameIndex,fTargetNSURI),
  -            (fTargetNSURI==-1) ? -1 : fCurrentScope, typeInfo.scopeDefined,
  +            (fTargetNSURI==StringPool.EMPTY_STRING) ? StringPool.EMPTY_STRING : fCurrentScope, typeInfo.scopeDefined,
               typeInfo.contentType, 
               typeInfo.contentSpecHandle, -1, typeInfo.datatypeValidator);
           return;
  @@ -2273,7 +3001,7 @@
                  if (typeInfo.contentSpecHandle == -2) {
                      typeInfo.contentSpecHandle = baseContentSpecHandle;
                  }
  -               else if (baseContentSpecHandle > -1) {
  +               else {
                      typeInfo.contentSpecHandle = 
                      fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_SEQ, 
                                                        baseContentSpecHandle,
  @@ -2305,7 +3033,7 @@
   
          typeInfo.templateElementIndex = fSchemaGrammar.addElementDecl(
               new QName(-1, templateElementNameIndex,typeNameIndex,fTargetNSURI),
  -            (fTargetNSURI==-1) ? -1 : fCurrentScope, typeInfo.scopeDefined,
  +            (fTargetNSURI==StringPool.EMPTY_STRING) ? StringPool.EMPTY_STRING : fCurrentScope, typeInfo.scopeDefined,
               typeInfo.contentType, 
               typeInfo.contentSpecHandle, -1, typeInfo.datatypeValidator);
          typeInfo.attlistHead = fSchemaGrammar.getFirstAttributeDeclIndex(
  @@ -2555,10 +3283,24 @@
           if (minOccurs.equals("")) {
               minOccurs = "1";
           }
  -        if (maxOccurs.equals("")) {
  +        if (CR_IMPL) { //CR IMPLEMENTATION
  +            if (maxOccurs.equals("")) {
                   maxOccurs = "1";
  +            }
  +        }
  +        else { //WORKING DRAFT IMPLEMENTATION
  +            if (maxOccurs.equals("") ){
  +            if ( minOccurs.equals("0")) {
  +                maxOccurs = "1";
  +            }
  +            else {
  +                maxOccurs = minOccurs;
  +            }
  +            }
           }
  +        
   
  +
           int leafIndex = index;
           //REVISIT: !!! minoccurs, maxoccurs.
           if (minOccurs.equals("1")&& maxOccurs.equals("1")) {
  @@ -2958,7 +3700,11 @@
               }
           }
   
  -        int uriIndex = -1;
  +        /***/
  +        // REVISIT: I don't think this code is right. The attribute
  +        //          should take on the target namespace of the grammar
  +        //          if present. -Ac
  +        int uriIndex = StringPool.EMPTY_STRING;
           // refer to 4.3.1 in "XML Schema Part 1: Structures"
           if ( fTargetNSURIString.length() > 0) {
                   if ( isAttrTopLevel) {
  @@ -2971,6 +3717,9 @@
                           }
                   }
           }
  +        /***
  +        int uriIndex = fTargetNSURI;
  +        /***/
   
           QName attQName = new QName(-1,attName,attName,uriIndex);
           if ( DEBUGGING )
  @@ -3740,17 +4489,43 @@
           fSchemaGrammar.setElementDeclSubstitutionGroupElementFullName(elementIndex, substitutionGroupFullName);
   
           //
  -        // key/keyref/unique processing\
  +        // key/keyref/unique processing
           //
   
           Element ic = XUtil.getFirstChildElement(elementDecl, IDENTITY_CONSTRAINTS);
  -        Vector idConstraints = null;
  -        
           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.getNextSiblingElement(ic, IDENTITY_CONSTRAINTS);
  +            }
  +        }
  +        
  +        return eltQName;
  +
  +    }// end of method traverseElementDecl(Element)
  +
  +    private void traverseIdentityConstraintsFor(int elementIndex,
  +                                                Vector identityConstraints)
  +        throws Exception {
  +
  +
  +        // iterate over identity constraints for this element
  +        int size = identityConstraints != null ? identityConstraints.size() : 0;
  +        if (size > 0) {
               // REVISIT: Use cached copy. -Ac
               XMLElementDecl edecl = new XMLElementDecl();
               fSchemaGrammar.getElementDecl(elementIndex, edecl);
  -            while (ic != null){
  +            for (int i = 0; i < size; i++) {
  +                Element ic = (Element)identityConstraints.elementAt(i);
                   String icName = ic.getLocalName();
                   if ( icName.equals(SchemaSymbols.ELT_KEY) ) { 
                       traverseKey(ic, edecl);
  @@ -3769,14 +4544,13 @@
                                                  "\""+SchemaSymbols.ELT_KEYREF+'"');
                   }
                   fSchemaGrammar.setElementDecl(elementIndex, edecl);
  -                ic = XUtil.getNextSiblingElement(ic, IDENTITY_CONSTRAINTS);
  -            }
  -        }
  -        
  -        return eltQName;
   
  -    }// end of method traverseElementDecl(Element)
  +            } // loop over vector elements
  +
  +        } // if size > 0
   
  +    } // traverseIdentityConstraints(Vector)
  +
       private void traverseUnique(Element uelem, XMLElementDecl edecl) 
           throws Exception {
   
  @@ -3842,8 +4616,20 @@
                        ? selem.getAttribute(SchemaSymbols.ATT_XPATH) 
                        : XUtil.getChildText(selem);
           stext = stext.trim();
  +        Selector.XPath sxpath = null;
           try {
  -            Selector.XPath sxpath = new Selector.XPath(stext, fStringPool, fNamespacesScope);
  +            // REVISIT: Must get ruling from XML Schema working group
  +            //          regarding whether steps in the XPath must be
  +            //          fully qualified if the grammar has a target
  +            //          namespace.
  +            //
  +            //          For now, I'm going to follow the identity
  +            //          constraint example in the XML Schema CR that
  +            //          doesn't fully qualify the steps (with the
  +            //          implied assumption that the URI for unqualified
  +            //          steps is equal to the target namespace). -Ac
  +            sxpath = new Selector.XPath(stext, fStringPool, 
  +                                        fNamespacesScope, fTargetNSURI);
               Selector selector = new Selector(sxpath, ic);
               if (DEBUG_IDENTITY_CONSTRAINTS) {
                   System.out.println("<IC>:   selector: "+selector);
  @@ -3852,10 +4638,12 @@
           }
           catch (XPathException e) {
               // REVISIT: Add error message.
  -            throw new SAXException(e.getMessage());
  +            reportGenericSchemaError(e.getMessage());
  +            return;
           }
   
           // get fields
  +        Element parent = (Element)icelem.getParentNode();
           Element felem = XUtil.getNextSiblingElement(selem, SchemaSymbols.ELT_FIELD);
           while (felem != null) {
               String ftext = CR_IMPL
  @@ -3863,9 +4651,24 @@
                            : XUtil.getChildText(felem);
               ftext = ftext.trim();
               try {
  -                Field.XPath fxpath = new Field.XPath(ftext, fStringPool, fNamespacesScope);
  +                // REVISIT: Must get ruling from XML Schema working group
  +                //          regarding whether steps in the XPath must be
  +                //          fully qualified if the grammar has a target
  +                //          namespace.
  +                //
  +                //          For now, I'm going to follow the identity
  +                //          constraint example in the XML Schema CR that
  +                //          doesn't fully qualify the steps (with the
  +                //          implied assumption that the URI for unqualified
  +                //          steps is equal to the target namespace). -Ac
  +                Field.XPath fxpath = new Field.XPath(ftext, fStringPool, 
  +                                                     fNamespacesScope, fTargetNSURI);
                   // REVISIT: Get datatype validator. -Ac
  -                Field field = new Field(fxpath, null, ic);
  +                DatatypeValidator validator = getDatatypeValidatorFor(parent, sxpath, fxpath);
  +                if (DEBUG_IC_DATATYPES) {
  +                    System.out.println("<ICD>: datatype validator: "+validator);
  +                }
  +                Field field = new Field(fxpath, validator, ic);
                   if (DEBUG_IDENTITY_CONSTRAINTS) {
                       System.out.println("<IC>:   field:    "+field);
                   }
  @@ -3873,13 +4676,142 @@
               }
               catch (XPathException e) {
                   // REVISIT: Add error message.
  -                throw new SAXException(e.getMessage());
  +                reportGenericSchemaError(e.getMessage());
  +                return;
               }
               felem = XUtil.getNextSiblingElement(felem, SchemaSymbols.ELT_FIELD);
           }
   
       } // traverseIdentityConstraint(IdentityConstraint,Element)
   
  +    private DatatypeValidator getDatatypeValidatorFor(Element element, 
  +                                                      Selector.XPath sxpath, 
  +                                                      Field.XPath fxpath)
  +        throws Exception {
  +
  +        // variables
  +        String ename = element.getAttribute("name");
  +        if (DEBUG_IC_DATATYPES) {
  +            System.out.println("<ICD>: XMLValidator#getDatatypeValidatorFor("+
  +                               ename+','+sxpath+','+fxpath+')');
  +        }
  +        int localpart = fStringPool.addSymbol(ename);
  +        String targetNamespace = fSchemaRootElement.getAttribute("targetNamespace");
  +        int uri = fStringPool.addSymbol(targetNamespace);
  +        int edeclIndex = fSchemaGrammar.getElementDeclIndex(uri, localpart, 
  +                                                            Grammar.TOP_LEVEL_SCOPE);
  +
  +        // walk selector
  +        XPath.LocationPath spath = sxpath.getLocationPath();
  +        XPath.Step[] ssteps = spath.steps;
  +        for (int i = 0; i < ssteps.length; i++) {
  +            XPath.Step step = ssteps[i];
  +            XPath.Axis axis = step.axis;
  +            XPath.NodeTest nodeTest = step.nodeTest;
  +            switch (axis.type) {
  +                case XPath.Axis.ATTRIBUTE: {
  +                    // REVISIT: Add message. -Ac
  +                    reportGenericSchemaError("not allowed to select attribute");
  +                    return null;
  +                }
  +                case XPath.Axis.CHILD: {
  +                    int index = fSchemaGrammar.getElementDeclIndex(nodeTest.name, edeclIndex);
  +                    if (index == -1) {
  +                        index = fSchemaGrammar.getElementDeclIndex(nodeTest.name, Grammar.TOP_LEVEL_SCOPE);
  +                    }
  +                    if (index == -1) {
  +                        // REVISIT: Add message. -Ac
  +                        reportGenericSchemaError("no such element "+fStringPool.toString(nodeTest.name.localpart));
  +                        return null;
  +                    }
  +                    edeclIndex = index;
  +                    break;
  +                }
  +                case XPath.Axis.SELF: {
  +                    // no-op
  +                    break;
  +                }
  +                default: {
  +                    // REVISIT: Add message. -Ac
  +                    reportGenericSchemaError("invalid selector axis");
  +                    return null;
  +                }
  +            }
  +        }
  +
  +        // walk field
  +        XPath.LocationPath fpath = fxpath.getLocationPath();
  +        XPath.Step[] fsteps = fpath.steps;
  +        for (int i = 0; i < fsteps.length; i++) {
  +            XPath.Step step = fsteps[i];
  +            XPath.Axis axis = step.axis;
  +            XPath.NodeTest nodeTest = step.nodeTest;
  +            switch (axis.type) {
  +                case XPath.Axis.ATTRIBUTE: {
  +                    if (i != fsteps.length - 1) {
  +                        // REVISIT: Add message. -Ac
  +                        reportGenericSchemaError("attribute must be last step");
  +                        return null;
  +                    }
  +                    // look up validator
  +                    int adeclIndex = fSchemaGrammar.getAttributeDeclIndex(edeclIndex, nodeTest.name);
  +                    if (adeclIndex == -1) {
  +                        // REVISIT: Add message. -Ac
  +                        reportGenericSchemaError("no such attribute "+fStringPool.toString(nodeTest.name.localpart));
  +                    }
  +                    XMLAttributeDecl adecl = new XMLAttributeDecl();
  +                    fSchemaGrammar.getAttributeDecl(adeclIndex, adecl);
  +                    DatatypeValidator validator = adecl.datatypeValidator;
  +                    return validator;
  +                }
  +                case XPath.Axis.CHILD: {
  +                    int index = fSchemaGrammar.getElementDeclIndex(nodeTest.name, edeclIndex);
  +                    if (index == -1) {
  +                        index = fSchemaGrammar.getElementDeclIndex(nodeTest.name, -1);
  +                    }
  +                    if (index == -1) {
  +                        // REVISIT: Add message. -Ac
  +                        reportGenericSchemaError("no such element "+fStringPool.toString(nodeTest.name.localpart));
  +                        return null;
  +                    }
  +                    edeclIndex = index;
  +                    if (i < fsteps.length - 1) {
  +                        break;
  +                    }
  +                    // NOTE: Let fall through to self case so that we
  +                    //       avoid duplicating code. -Ac
  +                }
  +                case XPath.Axis.SELF: {
  +                    // look up validator, if needed
  +                    if (i == fsteps.length - 1) {
  +                        XMLElementDecl edecl = new XMLElementDecl();
  +                        fSchemaGrammar.getElementDecl(edeclIndex, edecl);
  +                        if (edecl.type != XMLElementDecl.TYPE_SIMPLE) {
  +                            // REVISIT: Add message. -Ac
  +                            reportGenericSchemaError("selected element is not of simple type");
  +                            return null;
  +                        }
  +                        DatatypeValidator validator = edecl.datatypeValidator;
  +                        return validator;
  +                    }
  +                    break;
  +                }
  +                default: {
  +                    // REVISIT: Add message. -Ac
  +                    reportGenericSchemaError("invalid selector axis");
  +                    return null;
  +                }
  +            }
  +        }
  +
  +        // no validator!
  +        // REVISIT: Add message. -Ac
  +        reportGenericSchemaError("No datatype validator for field "+fxpath+
  +                                 " of element "+ename);
  +        return null;
  +
  +    } // getDatatypeValidatorFor(XPath):DatatypeValidator
  +
       private String getElementNameFor(Element icnode) {
           Element enode = (Element)icnode.getParentNode();
           String ename = enode.getAttribute("name");
  @@ -4063,6 +4995,29 @@
       }
   
       /**
  +     * Traverse attributeGroup Declaration
  +     * 
  +     *   <attributeGroup
  +     *         id = ID
  +     *         ref = QName>
  +     *         Content: (annotation?)
  +     *      </>
  +     * 
  +     * @param elementDecl
  +     * @exception Exception
  +     */
  +    /*private int traverseAttributeGroupDecl( Element attributeGroupDecl ) throws Exception {
  +        int attributeGroupID         =  fStringPool.addSymbol(
  +                                                             attributeGroupDecl.getAttribute( SchemaSymbols.ATTVAL_ID ));
  +
  +        int attributeGroupName      =  fStringPool.addSymbol(
  +                                                            attributeGroupDecl.getAttribute( SchemaSymbols.ATT_NAME ));
  +
  +        return -1;
  +    }*/
  +
  +
  +    /**
        * Traverse Group Declaration.
        * 
        * <group 
  @@ -4770,8 +5725,83 @@
               System.arraycopy(targetArray, tPos+1, newTargetArray, tPos, targetArray.length-tPos-1);
       } // end arrayProducer
   
  -        
  -        
  +    /****************************************
  +     * The following code is no longre used...
  +    // builds the all content model 
  +    private int buildAllModel(int children[], int count) throws Exception {
  +
  +        // build all model
  +        if (count > 1) {
  +
  +            // create and initialize singletons
  +            XMLContentSpec choice = new XMLContentSpec();
  +
  +            choice.type = XMLContentSpec.CONTENTSPECNODE_CHOICE;
  +            choice.value = -1;
  +            choice.otherValue = -1;
  +
  +            int[] exactChildren = new int[count];
  +            System.arraycopy(children,0,exactChildren,0,count);
  +            // build all model
  +            sort(exactChildren, 0, count);
  +            int index = buildAllModel(exactChildren, 0, choice);
  +
  +            return index;
  +        }
  +
  +        if (count > 0) {
  +            return children[0];
  +        }
  +
  +        return -1;
  +    }
  +
  +   // Builds the all model. 
  +    private int buildAllModel(int src[], int offset,
  +                              XMLContentSpec choice) throws Exception {
  +
  +        // swap last two places
  +        if (src.length - offset == 2) {
  +            int seqIndex = createSeq(src);
  +            if (choice.value == -1) {
  +                choice.value = seqIndex;
  +            }
  +            else {
  +                if (choice.otherValue != -1) {
  +                    choice.value = fSchemaGrammar.addContentSpecNode(choice.type, choice.value, choice.otherValue, false);
  +                }
  +                choice.otherValue = seqIndex;
  +            }
  +            swap(src, offset, offset + 1);
  +            seqIndex = createSeq(src);
  +            if (choice.value == -1) {
  +                choice.value = seqIndex;
  +            }
  +            else {
  +                if (choice.otherValue != -1) {
  +                    choice.value = fSchemaGrammar.addContentSpecNode(choice.type, choice.value, choice.otherValue, false);
  +                }
  +                choice.otherValue = seqIndex;
  +            }
  +            return fSchemaGrammar.addContentSpecNode(choice.type, choice.value, choice.otherValue, false);
  +        }
  +
  +        // recurse
  +        for (int i = offset; i < src.length - 1; i++) {
  +            choice.value = buildAllModel(src, offset + 1, choice);
  +            choice.otherValue = -1;
  +            sort(src, offset, src.length - offset);
  +            shift(src, offset, i + 1);
  +        }
  +
  +        int choiceIndex = buildAllModel(src, offset + 1, choice);
  +        sort(src, offset, src.length - offset);
  +
  +        return choiceIndex;
  +
  +    } // buildAllModel(int[],int,ContentSpecNode,ContentSpecNode):int
  +    ****************************************/
  +
       /** Creates a sequence. */
       private int createSeq(int src[]) throws Exception {
   
  @@ -4786,9 +5816,53 @@
   
           return fSchemaGrammar.addContentSpecNode(XMLContentSpec.CONTENTSPECNODE_SEQ,
                                                      left, right, false);
  +
  +    } // createSeq(int[]):int
  +
  +    /****************************************
  +     * More coe that is no longer necessary...
  +    // Shifts a value into position.    
  +    private void shift(int src[], int pos, int offset) {
  +
  +        int temp = src[offset];
  +        for (int i = offset; i > pos; i--) {
  +            src[i] = src[i - 1];
  +        }
  +        src[pos] = temp;
  +
  +    } // shift(int[],int,int)
  +
  +    // Simple sort. 
  +    private void sort(int src[], final int offset, final int length) {
  +
  +        for (int i = offset; i < offset + length - 1; i++) {
  +            int lowest = i;
  +            for (int j = i + 1; j < offset + length; j++) {
  +                if (src[j] < src[lowest]) {
  +                    lowest = j;
  +                }
  +            }
  +            if (lowest != i) {
  +                int temp = src[i];
  +                src[i] = src[lowest];
  +                src[lowest] = temp;
  +            }
  +        }
   
  -    }     
  +    } // sort(int[],int,int)
   
  +    // Swaps two values. 
  +    private void swap(int src[], int i, int j) {
  +
  +        int temp = src[i];
  +        src[i] = src[j];
  +        src[j] = temp;
  +
  +    } // swap(int[],int,int)
  +    ***************************************/
  +
  +    
  +
       // utilities from Tom Watson's SchemaParser class
       // TO DO: Need to make this more conformant with Schema int type parsing
   
  @@ -4801,7 +5875,22 @@
               }
       }
       
  -       
  +   //REVISIT: should remove after switching to CR!
  +   private int parseComplexDerivedBy (String derivedByString)  throws Exception
  +    {
  +            if ( derivedByString.equals (SchemaSymbols.ATTVAL_EXTENSION) ) {
  +                    return SchemaSymbols.EXTENSION;
  +            } 
  +            else if ( derivedByString.equals (SchemaSymbols.ATTVAL_RESTRICTION) ) {
  +                    return SchemaSymbols.RESTRICTION;
  +            } 
  +            else {
  +                // REVISIT: Localize
  +                    reportGenericSchemaError ( "ComplexType: Invalid value for 'derivedBy'" );
  +                    return -1;
  +            }
  +    }
  +    
       private int parseSimpleFinal (String finalString) throws Exception
       {
               if ( finalString.equals (SchemaSymbols.ATTVAL_POUNDALL) ) {
  
  
  
  1.3       +4 -3      xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Field.java	2001/01/25 07:18:54	1.2
  +++ Field.java	2001/02/01 09:58:43	1.3
  @@ -67,7 +67,7 @@
    * Schema identity constraint field.
    *
    * @author Andy Clark, IBM
  - * @version $Id: Field.java,v 1.2 2001/01/25 07:18:54 andyc Exp $
  + * @version $Id: Field.java,v 1.3 2001/02/01 09:58:43 andyc Exp $
    */
   public class Field {
   
  @@ -149,12 +149,13 @@
   
           /** Constructs a field XPath expression. */
           public XPath(String xpath, StringPool stringPool,
  -                     NamespacesScope context) throws XPathException {
  +                     NamespacesScope context, int targetNamespace) 
  +            throws XPathException {
               // NOTE: We have to prefix the field XPath with "./" in
               //       order to handle selectors such as "@attr" that 
               //       select the attribute because the fields could be
               //       relative to the selector element. -Ac
  -            super("./"+xpath, stringPool, context);
  +            super("./"+xpath, stringPool, context, targetNamespace);
           } // <init>(String,StringPool,NamespacesScope)
   
       } // class XPath
  
  
  
  1.4       +5 -4      xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Selector.java	2001/01/25 07:18:58	1.3
  +++ Selector.java	2001/02/01 09:58:43	1.4
  @@ -68,7 +68,7 @@
    * Schema identity constraint selector.
    *
    * @author Andy Clark, IBM
  - * @version $Id: Selector.java,v 1.3 2001/01/25 07:18:58 andyc Exp $
  + * @version $Id: Selector.java,v 1.4 2001/02/01 09:58:43 andyc Exp $
    */
   public class Selector {
   
  @@ -131,7 +131,7 @@
        * Schema identity constraint selector XPath expression.
        *
        * @author Andy Clark, IBM
  -     * @version $Id: Selector.java,v 1.3 2001/01/25 07:18:58 andyc Exp $
  +     * @version $Id: Selector.java,v 1.4 2001/02/01 09:58:43 andyc Exp $
        */
       public static class XPath
           extends org.apache.xerces.validators.schema.identity.XPath {
  @@ -142,12 +142,13 @@
       
           /** Constructs a selector XPath expression. */
           public XPath(String xpath, StringPool stringPool, 
  -                     NamespacesScope context) throws XPathException {
  +                     NamespacesScope context, int targetNamespace) 
  +            throws XPathException {
               // NOTE: We have to prefix the selector XPath with "./" in
               //       order to handle selectors such as "." that select
               //       the element container because the fields could be
               //       relative to that element. -Ac
  -            super("./"+xpath, stringPool, context);
  +            super("./"+xpath, stringPool, context, targetNamespace);
       
               // verify that an attribute is not selected
               XPath.Axis axis = fLocationPath.steps[fLocationPath.steps.length-1].axis;
  
  
  
  1.4       +29 -16    xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPath.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPath.java	2001/01/25 07:19:00	1.3
  +++ XPath.java	2001/02/01 09:58:44	1.4
  @@ -65,7 +65,7 @@
    * Bare minimum XPath parser.
    *
    * @author Andy Clark, IBM
  - * @version $Id: XPath.java,v 1.3 2001/01/25 07:19:00 andyc Exp $
  + * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
    */
   public class XPath {
   
  @@ -99,11 +99,12 @@
       //
   
       /** Constructs an XPath object from the specified expression. */
  -    public XPath(String xpath, StringPool stringPool, NamespacesScope context) 
  +    public XPath(String xpath, StringPool stringPool, 
  +                 NamespacesScope context, int targetNamespace) 
           throws XPathException {
           fExpression = xpath;
           fStringPool = stringPool;
  -        parseExpression(context);
  +        parseExpression(context, targetNamespace);
       } // <init>(String,StringPool,NamespacesScope)
   
       //
  @@ -132,8 +133,8 @@
        * This method is implemented by using the XPathExprScanner and
        * examining the list of tokens that it returns.
        */
  -    private void parseExpression(final NamespacesScope context) 
  -        throws XPathException {
  +    private void parseExpression(final NamespacesScope context,
  +                                 int targetNamespace) throws XPathException {
   
           // tokens
           final XPath.Tokens xtokens = new XPath.Tokens(fStringPool);
  @@ -201,9 +202,14 @@
                       }
                       token = xtokens.getToken(++i);
                       int prefix = xtokens.getTokenString(token);
  -                    int uri = context != null
  -                            ? context.getNamespaceForPrefix(prefix) : -1;
  -                    if (prefix != -1 && context != null && uri == -1) {
  +                    int uri = -1;
  +                    if (context != null && prefix != -1) {
  +                        uri = context.getNamespaceForPrefix(prefix);
  +                    }
  +                    if (uri == -1) {
  +                        uri = targetNamespace;
  +                    }
  +                    if (prefix != -1 && context != null && uri == StringPool.EMPTY_STRING) {
                           throw new XPathException("prefix "+fStringPool.toString(prefix)+" not bound to namespace URI");
                       }
                       token = xtokens.getToken(++i);
  @@ -241,9 +247,15 @@
                       // consume QName token
                       token = xtokens.getToken(++i);
                       int prefix = xtokens.getTokenString(token);
  -                    int uri = context != null
  -                            ? context.getNamespaceForPrefix(prefix) : -1;
  -                    if (prefix != -1 && context != null && uri == -1) {
  +                    int uri = -1;
  +                    if (context != null && prefix != -1) {
  +                        uri = context.getNamespaceForPrefix(prefix);
  +                    }
  +                    if (uri == -1) {
  +                        uri = targetNamespace;
  +                    }
  +                    if (prefix != -1 && context != null && 
  +                        uri == StringPool.EMPTY_STRING) {
                           throw new XPathException("prefix "+fStringPool.toString(prefix)+" not bound to namespace URI");
                       }
                       token = xtokens.getToken(++i);
  @@ -563,7 +575,7 @@
               switch (type) {
                   case QNAME: {
                       if (name.prefix != -1) {
  -                        if (name.uri == -1) {
  +                        if (name.uri == StringPool.EMPTY_STRING) {
                               return fStringPool.toString(name.prefix) + ':' + fStringPool.toString(name.localpart);
                           }
                           return "{" + fStringPool.toString(name.uri) + '}' + fStringPool.toString(name.prefix) + ':' + fStringPool.toString(name.localpart);
  @@ -600,7 +612,7 @@
        * @author Glenn Marcy, IBM
        * @author Andy Clark, IBM
        *
  -     * @version $Id: XPath.java,v 1.3 2001/01/25 07:19:00 andyc Exp $
  +     * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
        */
       private static final class Tokens {
       
  @@ -1058,7 +1070,7 @@
        * @author Glenn Marcy, IBM
        * @author Andy Clark, IBM
        *
  -     * @version $Id: XPath.java,v 1.3 2001/01/25 07:19:00 andyc Exp $
  +     * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
        */
       private static class Scanner {
       
  @@ -2136,7 +2148,7 @@
        * @author Glenn Marcy, IBM
        * @author Andy Clark, IBM
        *
  -     * @version $Id: XPath.java,v 1.3 2001/01/25 07:19:00 andyc Exp $
  +     * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
        */
       /***
       public static class XPathExprParser {
  @@ -3594,7 +3606,8 @@
               System.out.println("# XPath expression: \""+expression+'"');
               try {
                   StringPool stringPool = new StringPool();
  -                XPath xpath = new XPath(expression, stringPool, null);
  +                XPath xpath = new XPath(expression, stringPool, 
  +                                        null, StringPool.EMPTY_STRING);
                   System.out.println("expanded xpath: \""+xpath.toString()+'"');
               }
               catch (XPathException e) {
  
  
  
  1.6       +1 -13     xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java
  
  Index: XPathMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPathMatcher.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathMatcher.java	2001/01/25 07:19:01	1.5
  +++ XPathMatcher.java	2001/02/01 09:58:44	1.6
  @@ -75,7 +75,7 @@
    *
    * @author Andy Clark, IBM
    *
  - * @version $Id: XPathMatcher.java,v 1.5 2001/01/25 07:19:01 andyc Exp $
  + * @version $Id: XPathMatcher.java,v 1.6 2001/02/01 09:58:44 andyc Exp $
    */
   public class XPathMatcher {
   
  @@ -316,12 +316,6 @@
                   System.out.println(toString()+" [CHILD] before");
               }
               if (nodeTest.type == XPath.NodeTest.QNAME) {
  -                // REVISIT: Hack to work around current problem with schema
  -                //          validation setting the target namespace to the
  -                //          empty string. -Ac
  -                if (element.uri == StringPool.EMPTY_STRING) {
  -                    element.uri = -1;
  -                }
                   if (!nodeTest.name.equals(element)) {
                       fNoMatchDepth++;
                       if (DEBUG_MATCH) {
  @@ -355,12 +349,6 @@
                       int alocalpart = attributes.getAttrLocalpart(aindex);
                       int arawname = attributes.getAttrName(aindex);
                       int auri = attributes.getAttrURI(aindex);
  -                    // REVISIT: Hack to work around current problem with schema
  -                    //          validation setting the target namespace to the
  -                    //          empty string. -Ac
  -                    if (auri == StringPool.EMPTY_STRING) {
  -                        auri = -1;
  -                    }
                       aname.setValues(aprefix, alocalpart, arawname, auri);
                       if (nodeTest.type != XPath.NodeTest.QNAME ||
                           nodeTest.name.equals(aname)) {
  
  
  

Mime
View raw message