Re: Element name duplication

Hi,

> 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".

Or you can add co-occurence constraints to the XML Schema by embedding
Schematron rules that check this extra constraint. See [1] for more information
on this.

Cheers,
/Eddie

[1] http://www.topologi.com/public/Schtrn_XSD/Paper.html

>
>
> Bob
>
> 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 20:01:11 UTC