W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2001

Howto: Enforce unique attribute

From: Chris Aaa <chrisaaa@email.com>
Date: Wed, 25 Apr 2001 11:33:38 -0400 (EDT)
Message-ID: <384151134.988212819399.JavaMail.root@web576-ec>
To: www-xml-schema-comments@w3.org
Sorry, i'm new to this and now have to consume XML so am writing an XSD, I
am stuck on how to make the validator enforce a unique attribute, I am stuck
with the XML format and have to make the xsd match!

===========================================================<!-- cut down xml
-->
<ConfigurationInformation>
<Streams>
<Stream Num="1">
<IP>10.10.10.10</IP>
<!-- 191.137.98.105 when validator fixed -->
</Stream>
<Stream Num="1"> <!-- ##### I want an error here ##### -->
<IP>10.10.10.10</IP>
</Stream>
<Stream Num="2">
<IP>10.10.10.10</IP>
</Stream>
</Streams>
</ConfigurationInformation>
===========================================================

I would like to detect there are 2 streams with Num=1, it must be possible
but I cannot work it out.

My [cut down] validation file, don't laugh.
===========================================================
<xsd:element name="ConfigurationInformation">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Streams" type="adh:Streams"
minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
<xsd:anyAttribute/>
</xsd:complexType>
</xsd:element>

<xsd:complexType name="Streams">
<xsd:sequence>
<xsd:element name="Stream" type="adh:Stream" minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:anyAttribute/>
</xsd:complexType>

<xsd:complexType name="Stream">
<xsd:sequence>
<xsd:element name="IP" type="xds:string"
minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="Num" type="xsd:string" use="required"/>
<xsd:anyAttribute/>
</xsd:complexType>

===========================================================

MTIA

Chris


-----------------------------------------------
FREE! The World's Best Email Address @email.com
Reserve your name now at http://www.email.com
Received on Wednesday, 25 April 2001 11:33:43 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:12:50 GMT