W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2002

Re: Element name duplication

From: Eddie Robertsson <erobertsson@allette.com.au>
Date: Thu, 30 May 2002 10:13:29 +1000
Message-ID: <3CF56EA9.E2B0B9AA@allette.com.au>
To: Colin Mackenzie <colin@elecmc.com>
CC: AMADOU Vincent <vincent.amadou@post.be>, xmlschema-dev@w3.org

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:56 UTC