Mishandling of recursive definition on complex content restriction
------------------------------------------------------------------

         Key: XERCESC-1591
         URL: http://issues.apache.org/jira/browse/XERCESC-1591
     Project: Xerces-C++
        Type: Bug

  Components: Validating Parser (Schema) (Xerces 1.5 or up only)  
    Versions: 2.6.0    
 Environment: Windows XP
    Reporter: Andrew Fang


When trying to the following schema in Xerces 2.6, it complains that the base 
type of CV does not have any attribute defined (Line: 34 Column: 31
Base type definition does not have any attributes). Apparently, we see 
attribute defined in CE (the base type of CV).

The problem seems to be caused by element "qualifier" in complexType "CD". The 
element "qualifier" has type of CR which contains an element of type CV which 
is a derivative of CE, which in turns is the derivative of CD. Xerces trys to 
resolve CE before attributes in CD is processed and thus the error.

Although the syntax looks wierd, it  is from a govenment stanadard and we have 
no position of changing that.

A workaround is to move definition of CR ahead of CD. However, since the 
position of element definition in Schema should have no effect on validation, 
we think Xerces should report no error as it is.


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="urn:hl7-org:v3"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns="urn:hl7-org:v3" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema";
        elementFormDefault="qualified">

        <xsd:complexType name="ANY" abstract="true"></xsd:complexType>

        <xsd:complexType name="CD">
                <xsd:complexContent>
                        <xsd:extension base="ANY">
                                <xsd:sequence>
                                        <xsd:element name="qualifier" type="CR"
                                                minOccurs="0" 
maxOccurs="unbounded"/>
                                </xsd:sequence>
                                <xsd:attribute name="code" use="optional"/>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>

        <xsd:complexType name="CE">
                <xsd:complexContent>
                        <xsd:restriction base="CD">
                                <xsd:sequence>
                                </xsd:sequence>
                                <xsd:attribute name="code" use="optional"/>
                        </xsd:restriction>
                </xsd:complexContent>
        </xsd:complexType>

        <xsd:complexType name="CV">
                <xsd:complexContent>
                        <xsd:restriction base="CE">
                                <xsd:sequence>

                                </xsd:sequence>
                                <xsd:attribute name="code" use="optional"/>
                        </xsd:restriction>
                </xsd:complexContent>
        </xsd:complexType>

        <xsd:complexType name="CR">
                <xsd:complexContent>
                        <xsd:extension base="ANY">
                                <xsd:sequence>
                                        <xsd:element name="name" type="CV" 
minOccurs="0"
                                                maxOccurs="1"/>
                                </xsd:sequence>
                                <xsd:attribute name="inverted" use="optional"
                                        default="false"/>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>

        <xsd:element name="root" type="CV" />

</xsd:schema>

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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

Reply via email to