Re: Element name duplication

                                                                                                               
                                                                                                               
                                                                                                               


You can use something like:

<xs:element name="myElement">
    <xs:complexType>
     <xs:sequence>
        <xs:element name="code" type="xs"integer"/>
        <xs:element name="description" minOccurs="2" maxOccurs="2">
         <xs:simpleContent>
           <xs:extension base="xs:string">
             <xs:attribute ref="language"/>
           </xs:extension>
         </xs:simpleContent>
        </xs:element>
     </xs:sequence>
   </xs:complexType>
</xs:element>

<xs:attribute name="language">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="fr"/>
      <xs:enumeration value="en"/>
    </xs:restriction>
  </xs:simpleType>
</xs:attribute>

Because XML Schema 1.0 lacks general co-occurance constraints, you cannot
specify that exactly one of the 2 description elements in the sequence must
have attribute   language="en"  and exactly one of the 2 description
elements in the sequence must have attribute    language="fr".

Bob



AMADOU Vincent <vincent.amadou@post.be>@w3.org on 05/28/2002 09:16:05 AM

Sent by:    xmlschema-dev-request@w3.org


To:    "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
cc:
Subject:    Element name duplication





Hi,

  I would like to define a Xml Schema for this piece of XML:

 <myElement>
        <code>22</code>
        <description language="en">xxxxxxx</description>
        <description language="fr">xxxxxxx</description>
 <myElement>

where both "description" tag are required. How can I specify this with Xml
Schema ?

Thanks

Vincent

Received on Wednesday, 29 May 2002 07:42:05 UTC