You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by ji...@apache.org on 2004/04/12 23:26:02 UTC

[jira] Updated: (XERCERJ-448) validating "All" group, once an error, will report all next tags invalid

The following issue has been updated:

    Updater: Serge Knystautas (mailto:sergek@lokitech.com)
       Date: Mon, 12 Apr 2004 2:25 PM
    Changes:
             Attachment changed from test.xml
    ---------------------------------------------------------------------
For a full history of the issue, see:

  http://issues.apache.org/jira/browse/XERCERJ-448?page=history

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCERJ-448

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCERJ-448
    Summary: validating "All" group, once an error, will report all next tags invalid
       Type: Bug

     Status: Resolved
 Resolution: FIXED

    Project: Xerces2-J

   Assignee: Xerces-J Developers Mailing List
   Reporter: Dave

    Created: Tue, 27 Aug 2002 3:50 AM
    Updated: Mon, 12 Apr 2004 2:25 PM
Environment: Operating System: Other
Platform: All

Description:
See attached test files. Once the schema validation fails for the "all" group,
in this test case on the t41 element, it will report all remaining elements
invalid, even t2 which is valid.

A quick look at the code shows that in XMLSchemaValidator (line 1794 in the
latest cvs rev 1.87 of the file, see below) in the if statement adding a check
for decl==null solves the problem.

Reasoning behind the change: if I understand the code correctly,
fCurrentCM.oneTransition() will return "null" if and only if the element does
not match any of the allowed elements.

Please make sure the proposed change does not have other side effects.

Note: even after the fix there are still somewhat inconsistent error reporting
(play with the t41, t42, and t43 tags and see how those are reported as errors,
how the errors reported are restarted after every valid element), but my I think
it is good enough and further checking will only slow down the validation
process without signifficant benefit. 

Regards,
Dave

---<where to patch: XMLSchemaValidator.java, cvs rev 1.87, line 1794>---

        // if we are not skipping this element, and there is a content model,
        // we try to find the corresponding decl object for this element.
        // the reason we move this part of code here is to make sure the
        // error reported here (if any) is stored within the parent element's
        // context, instead of that of the current element.
        Object decl = null;
        if (fSkipValidationDepth < 0 && fCurrentCM != null) {
            decl = fCurrentCM.oneTransition(element, fCurrCMState,
fSubGroupHandler);
            // it could be an element decl or a wildcard decl
--->THIS LINE--->            if (decl==null && fCurrCMState[0] ==
XSCMValidator.FIRST_ERROR && fDoValidation) {
                XSComplexTypeDecl ctype = (XSComplexTypeDecl)fCurrentType;
                //REVISIT: is it the only case we will have particle = null?
                if (ctype.fParticle != null) {
                    reportSchemaError("cvc-complex-type.2.4.a", new
Object[]{element.rawname, ctype.fParticle.toString()});
                }
                else {
                    reportSchemaError("cvc-complex-type.2.4.a", new
Object[]{element.rawname, "mixed with no element content"});
                }
            }
        }



---<this is the test.xml>---

<?xml version="1.0"?>
<t xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="test.xsd">
 <tt>
  <t1>test1</t1>
  <t4>zzz</t4>
  <t3>test2</t3>
 </tt>
 <tt>
  <t3>test3</t3>
  <t1>test1</t1>
  <t41>zzz</t41>
  <t43>zzz</t43>
  <t2>test2</t2>
  <t42>zzz</t42>
 </tt>
</t>

---<this is the test.xsd>---

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
 <xsd:complexType name="z">
  <xsd:all>
    <xsd:element name="t1"/>
    <xsd:element name="t2" minOccurs="0"/>
    <xsd:element name="t3"/>
    <xsd:element name="t4"/>
  </xsd:all>
 </xsd:complexType>

<xsd:element name="t">
 <xsd:complexType>
  <xsd:sequence>
   <xsd:element name="tt" type="z" maxOccurs="unbounded"/>
  </xsd:sequence>
 </xsd:complexType>
</xsd:element>

</xsd:schema>


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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