Errors using substitution groups in restrictions
------------------------------------------------

                 Key: XERCESJ-1306
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1306
             Project: Xerces2-J
          Issue Type: Bug
          Components: XML Schema Structures
    Affects Versions: 2.9.1
         Environment: Xerces-J 2.9.1 within Oxygen 9.0 in MacOSX
            Reporter: Fabio Vitali


I am trying to go from abstract to concrete using substitution groups. So far I 
have not managed, and I am wondering why: 

Example: 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>

    <xs:element name="heading" type="block"                 abstract="true" />
    <xs:element name="number"  substitutionGroup="heading"/>
    <xs:element name="title"   substitutionGroup="heading"/>
       
     <xs:complexType name="block" mixed="true">
        <xs:choice>
            <xs:element name="b" type="block"/>
            <xs:element name="i" type="block"/>
        </xs:choice>
    </xs:complexType>
        
    <xs:element name="hcontainer" type="hierarchicalContainer" abstract="true" 
/>
    <xs:element name="section"    substitutionGroup="hcontainer"/>
    <xs:element name="chapter"    substitutionGroup="hcontainer"/>
    
    <xs:complexType name="hierarchicalContainer" abstract="true">
        <xs:sequence>
            <xs:element ref="heading" maxOccurs="unbounded"/>
            <xs:element ref="hcontainer" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="bookType1">
        <xs:complexContent>
            <xs:restriction base="hierarchicalContainer">
                <xs:sequence>
                    <xs:element ref="number"/>
                    <xs:element ref="chapter" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
   
</xs:schema>

--

Error

rcase-Recurse.2: There is not a complete functional mapping between the 
particles.
URL: http://www.w3.org/TR/xmlschema-1/#rcase-Recurse

derivation-ok-restriction.5.4.2: Error for type 'bookType1'.  The particle of 
the type is not a valid restriction of the particle of the base.
URL: http://www.w3.org/TR/xmlschema-1/#derivation-ok-restriction


Comments

To my knowledge, BookType1 should work: number is substitutable for heading and 
maxOccurs of the restriction is less than maxOccurs of the base, chapter is 
substitutable for hcontainer, and maxOccurs of the restriction is equal to 
maxOccurs of the base. So to my knowledge this should note pose problems. Yet...

Notes

Funny that if I only substitute the first name of the two elements, it suddenly 
works. The following example is identical except that "chapter" has gone back 
to the abstract element "hcontainer". 

    <xs:complexType name="bookType2">
        <xs:complexContent>
            <xs:restriction base="hierarchicalContainer">
                <xs:sequence>
                    <xs:element ref="number" />
                    <xs:element ref="hcontainer" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

Even funnier i that if I remove the repeatability of the hcontainer it also 
works. The following example is as the first one, except that I am forbidding 
repeatability of element "chapter". This is accepted and generates no error. 

   <xs:complexType name="bookType3">
        <xs:complexContent>
            <xs:restriction base="hierarchicalContainer">
                <xs:sequence>
                    <xs:element ref="number"/>
                    <xs:element ref="chapter"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>    

Any idea of why it works this way?

Regards

Fabio



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to