neilg       2002/08/12 11:12:24

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
               java/src/org/apache/xerces/impl/xs/identity Selector.java
                        XPathMatcher.java
  Log:
  identity constraint fix.  Since character content is buffered and normalized in 
XMLSchemaValidator so that
  it can be made available through the PSVI, no need to buffer it in identity 
constraints.  Therefore, removed
  characters callback and added an ElementPSVI object to the endElement  callback.
  
  Revision  Changes    Path
  1.78      +3 -39     
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- XMLSchemaValidator.java   18 Jul 2002 15:10:33 -0000      1.77
  +++ XMLSchemaValidator.java   12 Aug 2002 18:12:24 -0000      1.78
  @@ -854,22 +854,6 @@
           if (!allWhiteSpace) {
               fSawCharacters = true;
           }
  -        //  call all active identity constraints
  -        // REVISIT -IC: we need a matcher.characters(String)
  -        int count = fMatcherStack.getMatcherCount();
  -        XMLString text = null;
  -        if (count > 0) {
  -            //REVISIT-IC: Should we pass normalize data?
  -            int bufLen = data.length();
  -            char [] chars = new char[bufLen];
  -            data.getChars(0, bufLen, chars, 0);
  -            text = new XMLString(chars, 0, bufLen);
  -        }
  -        for (int i = 0; i < count; i++) {
  -            XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
  -            matcher.characters(text);
  -        }
  -
           return allWhiteSpace;
       }
       
  @@ -1158,7 +1142,7 @@
   
       /**
        * Stack of active XPath matchers for identity constraints. All
  -     * active XPath matchers are notified of startElement, characters
  +     * active XPath matchers are notified of startElement
        * and endElement callbacks in order to perform their matches.
        * <p>
        * For each element with identity constraints, the selector of
  @@ -1585,12 +1569,6 @@
               fSawCharacters = true;
           }
   
  -        // call all active identity constraints
  -        int count = fMatcherStack.getMatcherCount();
  -        for (int i = 0; i < count; i++) {
  -            XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
  -            matcher.characters(text);
  -        }
       } // handleCharacters(XMLString)
   
       /**
  @@ -1698,13 +1676,6 @@
           if (fSkipValidationDepth >= 0)
               return;
   
  -        // call all active identity constraints
  -        int count = fMatcherStack.getMatcherCount();
  -        for (int i = 0; i < count; i++) {
  -            XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
  -            matcher.characters(text);
  -        }
  -
       } // handleIgnorableWhitespace(XMLString)
   
       /** Handle element. */
  @@ -2108,7 +2079,7 @@
           int oldCount = fMatcherStack.getMatcherCount();
           for (int i = oldCount - 1; i >= 0; i--) {
               XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
  -            matcher.endElement(element, fCurrentElemDecl);
  +            matcher.endElement(element, fCurrentElemDecl, fCurrentPSVI);
           }
           if (fMatcherStack.size() > 0) {
               fMatcherStack.popContext();
  @@ -2762,13 +2733,6 @@
               char [] chars = new char[bufLen];
               fCurrentElemDecl.fDefault.normalizedValue.getChars(0, bufLen, chars, 0);
               defaultValue = new XMLString(chars, 0, bufLen);
  -            // call all active identity constraints
  -            int count = fMatcherStack.getMatcherCount();
  -            for (int i = 0; i < count; i++) {
  -                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
  -                matcher.characters(defaultValue);
  -            }
  -
           }
           // fixed values are handled later, after xsi:type determined.
   
  
  
  
  1.5       +5 -4      
xml-xerces/java/src/org/apache/xerces/impl/xs/identity/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/Selector.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Selector.java     15 Apr 2002 19:46:24 -0000      1.4
  +++ Selector.java     12 Aug 2002 18:12:24 -0000      1.5
  @@ -63,6 +63,7 @@
   import org.apache.xerces.xni.QName;
   import org.apache.xerces.xni.XNIException;
   import org.apache.xerces.xni.XMLAttributes;
  +import org.apache.xerces.xni.psvi.ElementPSVI;
   import org.apache.xerces.util.SymbolTable;
   import org.apache.xerces.impl.xs.XSElementDecl;
   import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
  @@ -243,8 +244,8 @@
   
           } // startElement(QName,XMLAttrList,int)
   
  -        public void endElement(QName element, XSElementDecl eDecl) {
  -            super.endElement(element, eDecl);
  +        public void endElement(QName element, XSElementDecl eDecl, ElementPSVI 
ePSVI) {
  +            super.endElement(element, eDecl, ePSVI);
               if (fElementDepth-- == fMatchedDepth) {
                   fMatchedDepth = -1;
                   fFieldActivator.endValueScopeFor(fIdentityConstraint);
  
  
  
  1.7       +5 -35     
xml-xerces/java/src/org/apache/xerces/impl/xs/identity/XPathMatcher.java
  
  Index: XPathMatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/identity/XPathMatcher.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XPathMatcher.java 15 Jul 2002 20:24:27 -0000      1.6
  +++ XPathMatcher.java 12 Aug 2002 18:12:24 -0000      1.7
  @@ -74,6 +74,7 @@
   import org.apache.xerces.xni.QName;
   import org.apache.xerces.xni.XMLAttributes;
   import org.apache.xerces.xni.XMLString;
  +import org.apache.xerces.xni.psvi.ElementPSVI;
   
   /**
    * XPath matcher.
  @@ -269,13 +270,9 @@
               fStepIndexes[i].clear();
               fCurrentStep[i] = 0;
               fNoMatchDepth[i] = 0;
  -            fMatched[i]=false;
           }
   
           // keep values
  -        /****
  -        fNamespacesScope = context;
  -        */
           fSymbolTable = symbolTable;
   
       } // startDocumentFragment(NamespaceContext)
  @@ -470,30 +467,6 @@
   
       } // startElement(QName,XMLAttrList,int)
   
  -    /** Character content. */
  -    public void characters(XMLString text)
  -        throws XNIException {
  -        if (DEBUG_METHODS) {
  -            System.out.println(toString()+"#characters("+
  -                               "text="+normalize(text.toString())+
  -                               ")");
  -        }
  -
  -        // collect match content
  -        // so long as one of our paths is matching, store the content
  -        for(int i=0; i<fLocationPaths.length; i++)
  -            if (fBufferContent && fNoMatchDepth[i] == 0) {
  -                if (!DEBUG_METHODS && DEBUG_METHODS2) {
  -                    System.out.println(toString()+"#characters("+
  -                                   "text="+normalize(text.toString())+
  -                                   ")");
  -                }
  -                fMatchedBuffer.append(text);
  -                break;
  -            }
  -
  -    } // characters(char[],int,int)
  -
       /**
        * The end of an element.
        *
  @@ -502,7 +475,7 @@
        *
        * @throws SAXException Thrown by handler to signal an error.
        */
  -    public void endElement(QName element, XSElementDecl eDecl) {
  +    public void endElement(QName element, XSElementDecl eDecl, ElementPSVI ePSVI) {
           if (DEBUG_METHODS2) {
               System.out.println(toString()+"#endElement("+
                                  "element={"+element+"},"+
  @@ -522,9 +495,7 @@
                   if (j<i) continue;
                   if (fBufferContent) {
                       fBufferContent = false;
  -                    fMatchedString = fMatchedBuffer.toString();
  -                    // REVISIT: cache this.
  -                    // REVISIT:  make sure type's from same schema!
  +                    fMatchedString = ePSVI.getSchemaNormalizedValue();
                       // REVISIT:  make sure type is simple!
                       XSSimpleType val=null;
   
  @@ -569,7 +540,6 @@
           if (DEBUG_METHODS) {
               System.out.println(toString()+"#endDocumentFragment()");
           }
  -        clear();
       } // endDocumentFragment()
   
       //
  @@ -618,7 +588,7 @@
           fBufferContent = false;
           fMatchedBuffer.setLength(0);
           fMatchedString = null;
  -        for(int i = 0; i<fLocationPaths.length; i++)
  +        for(int i = 0; i < fLocationPaths.length; i++) 
               fMatched[i] = false;
       } // clear()
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to