mrglavas    2005/07/24 15:55:21

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
  Log:
  Fixing JIRA Issue #1090:
  http://issues.apache.org/jira/browse/XERCESJ-1090
  
  Clause 2.1 of Section 3.4.4 of Part 1: Structures says:  "If the {content 
type} is empty,
  then the element information item has no character or element information 
item [children]".
  
  Section 3.1.4 says: "... comments and processing instructions, even in the
  midst of text, are ignored for all ·validation· purposes".
  
  The schema validator was reporting an error if a comment or processing 
instruction was
  present as a child of an element declared to have empty content. This 
behaviour
  was introduced in CVS v1.28 when it was thought that errors should be 
reported for
  such content.
  
  Revision  Changes    Path
  1.179     +5 -24     
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.178
  retrieving revision 1.179
  diff -u -r1.178 -r1.179
  --- XMLSchemaValidator.java   23 Jun 2005 17:58:52 -0000      1.178
  +++ XMLSchemaValidator.java   24 Jul 2005 22:55:21 -0000      1.179
  @@ -977,10 +977,7 @@
        * @throws XNIException Thrown by application to signal an error.
        */
       public void comment(XMLString text, Augmentations augs) throws 
XNIException {
  -
  -        // record the fact that there is a comment child.
  -        fSawChildren = true;
  -
  +        
           // call handlers
           if (fDocumentHandler != null) {
               fDocumentHandler.comment(text, augs);
  @@ -1008,9 +1005,6 @@
       public void processingInstruction(String target, XMLString data, 
Augmentations augs)
           throws XNIException {
   
  -        // record the fact that there is a PI child.
  -        fSawChildren = true;
  -
           // call handlers
           if (fDocumentHandler != null) {
               fDocumentHandler.processingInstruction(target, data, augs);
  @@ -1170,12 +1164,6 @@
       /** Stack to record if we saw character data outside of element content*/
       private boolean[] fStringContent = new boolean[INITIAL_STACK_SIZE];
   
  -    /** Did we see children that are neither characters nor elements? */
  -    private boolean fSawChildren = false;
  -
  -    /** Stack to record if we other children that character or elements */
  -    private boolean[] fSawChildrenStack = new boolean[INITIAL_STACK_SIZE];
  -
       /** temporary qname */
       private final QName fTempQName = new QName();
   
  @@ -1534,10 +1522,6 @@
               fStringContent = newArrayB;
   
               newArrayB = new boolean[newSize];
  -            System.arraycopy(fSawChildrenStack, 0, newArrayB, 0, 
fElementDepth);
  -            fSawChildrenStack = newArrayB;
  -
  -            newArrayB = new boolean[newSize];
               System.arraycopy(fStrictAssessStack, 0, newArrayB, 0, 
fElementDepth);
               fStrictAssessStack = newArrayB;
   
  @@ -1813,7 +1797,6 @@
               fCMStateStack[fElementDepth] = fCurrCMState;
               fSawTextStack[fElementDepth] = fSawText;
               fStringContent[fElementDepth] = fSawCharacters;
  -            fSawChildrenStack[fElementDepth] = fSawChildren;
           }
   
           // increase the element depth after we've saved
  @@ -1830,7 +1813,6 @@
           fBuffer.setLength(0);
           fSawText = false;
           fSawCharacters = false;
  -        fSawChildren = false;
   
           // check what kind of declaration the "decl" from
           // oneTransition() maps to
  @@ -2112,8 +2094,8 @@
                   fCurrCMState = fCMStateStack[fElementDepth];
                   fSawText = fSawTextStack[fElementDepth];
                   fSawCharacters = fStringContent[fElementDepth];
  -                fSawChildren = fSawChildrenStack[fElementDepth];
  -            } else {
  +            } 
  +            else {
                   fElementDepth--;
               }
   
  @@ -2240,7 +2222,6 @@
               fCurrCMState = fCMStateStack[fElementDepth];
               fSawText = fSawTextStack[fElementDepth];
               fSawCharacters = fStringContent[fElementDepth];
  -            fSawChildren = fSawChildrenStack[fElementDepth];
   
               // We should have a stack for whitespace value, and pop it up 
here.
               // But when fWhiteSpace != -1, and we see a sub-element, it must 
be
  @@ -3109,7 +3090,7 @@
           if (!fNil) {
               // 2.1 If the {content type} is empty, then the element 
information item has no character or element information item [children].
               if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY
  -                && (fSubElement || fSawText || fSawChildren)) {
  +                && (fSubElement || fSawText)) {
                   reportSchemaError("cvc-complex-type.2.1", new Object[] { 
element.rawname });
               }
               // 2.2 If the {content type} is a simple type definition, then 
the element information item has no element information item [children], and 
the normalized value of the element information item is valid with respect to 
that simple type definition as defined by String Valid (3.14.4).
  
  
  

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

Reply via email to