Hello everyone,

I have been trying to "extend" a type which allows xsd:choice model group to add a couple of more allowed choice elements. Here's the original xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.myapp.org/xml/ns/myapp"
            xmlns:myapp="http://www.myapp.org/xml/ns/myapp"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <xsd:element name="graphics" type="graphicsType/>

    <xsd:complexType name="graphicsType">
        <xsd:sequence>
            <xsd:element name="colours" type="coloursType"/>
        </xsd:sequence>
    </xsd:complexType>
    

    <xsd:complexType name="coloursType">
        <xsd:choice maxOccurs="unbounded">
              <xsd:element name="red">
            <xsd:complexType />
        </xsd:elemen>
        <xsd:element name="blue">
            <xsd:complexType />
        </xsd:element>          
       </xsd:choice>
    </xsd:complexType>        
</xsd:schema>


The extended xsd is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.myapp.org/xml/ns/myapp"
            xmlns:myapp="http://www.myapp.org/xml/ns/myapp"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            version="1.0">

    <xsd:element name="extended-graphics" type="extended-graphicsType/>
    
    <xsd:complexType name="extended-graphicsType">
        <xsd:extension base="graphicsType">
            <xsd:sequence>
                <xsd:element name="brush" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexType>

    <xsd:complexType name="more-coloursType" >
        <xsd:extension base="coloursType">
                <xsd:choice maxOccurs="unbounded">
                      <xsd:element name="dark-red">
                    <xsd:complexType />
                </xsd:elemen>
                <xsd:element name="dark-blue">
                    <xsd:complexType />
                </xsd:element>        
               </xsd:choice>
        </xsd:extension>
    </xsd:complexType>
        
</xsd:schema>

So here i have a "coloursType" with a choice of "red" and "blue" and the extended "more-coloursType" has the additional "dark-red" and "dark-blue". Then in my xml i am trying to do this:

<extended-graphics xmlns="http://www.myapp.org/xml/ns/myapp"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:myapp="http://www.myapp.org/xml/ns/myapp">

    <colours xsi:type="more-coloursType">
        <dark-red/>
    </colour>                 
                 
</extended-graphics>     
 

So in the xml, i am trying to use the extended "more-coloursType" and specifying a "dark-red" value. But this fails validation, with a message saying that "dark-red" is not allowed in this place. It starts working if i first have a normal colour (either red or blue) and then have dark-red:

<colours xsi:type="more-coloursType">
        <blue/>
        <dark-red/>
    </colour>   

My understanding was with this kind of extension, with the "choice" elements i would have something like:

(red | blue)* (dark-red | dark-blue)*

but this doesn't seem to be the case. Am i missing something? Are there any changes that i'll have to make to my xsd to allow:

     <colours xsi:type="more-coloursType">
        <dark-red/>
    </colour> 

regards,
-Jaikiran


The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.