- From: Ashok Malhotra <ashokma@microsoft.com>
- Date: Wed, 25 Apr 2001 09:03:12 -0700
- To: "Chris Aaa" <chrisaaa@email.com>, <www-xml-schema-comments@w3.org>
Chris: You said: > I would like to detect there are 2 streams with Num=1, > it must be possible but I cannot work it out. You can define the attribute as a key and the system Will check whether it is unique. Regards, Ashok -----Original Message----- From: Chris Aaa [mailto:chrisaaa@email.com] Sent: Wednesday, April 25, 2001 8:34 AM To: www-xml-schema-comments@w3.org Subject: Howto: Enforce unique attribute 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 12:06:45 UTC