- From: Colin Mackenzie <colin@elecmc.com>
- Date: Wed, 29 May 2002 13:02:11 +0100
- To: "AMADOU Vincent" <vincent.amadou@post.be>, <xmlschema-dev@w3.org>
or, if you have a limited and fixed amount of languages to support it may be better to specify the language as an element names thus ensuring that all of the languages will be present and not duplicated e.g. <?xml version="1.0" encoding="UTF-8"?> <myElement> <code>22</code> <en>xxxxxxx</en> <fr>xxxxxxx</fr> </myElement> with the schema <?xml version="1.0" encoding="UTF-8"?> <!--W3C Schema generated by XML Spy v4.3 U (http://www.xmlspy.com)--> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="myElement"> <xs:complexType> <xs:sequence> <xs:element name="code" type="xs:byte"/> <xs:element name="en" type="xs:string"/> <xs:element name="fr" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> if you need you place restrictions on the descxription text then you would replace the type 0f xs:string with your own complexType of description. Colin -----Original Message----- From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org]On Behalf Of Bob Schloss Sent: 29 May 2002 12:40 To: AMADOU Vincent; xmlschema-dev@w3.org Subject: 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 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 08:06:52 UTC