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

RE: Element name duplication

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

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"
	<xs:element name="myElement">
				<xs:element name="code" type="xs:byte"/>
				<xs:element name="en" type="xs:string"/>
				<xs:element name="fr" type="xs:string"/>

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.


-----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:element name="code" type="xs"integer"/>
<xs:element name="description" minOccurs="2" maxOccurs="2">
<xs:extension base="xs:string">
<xs:attribute ref="language"/>

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

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


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


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

        <description language="en">xxxxxxx</description>
        <description language="fr">xxxxxxx</description>

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


Received on Wednesday, 29 May 2002 08:06:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:02 UTC