tipone Posted December 11, 2009 Share Posted December 11, 2009 Hi, gurus! I have a list of values in element <Paz><StatussR> <Paz>A</Paz> <Paz>B</Paz> <Paz>C</Paz></StatussR>I want not to allow to repeat a values in <Paz> in <StatussR> element. for example:<StatussR> <Paz>A</Paz> <Paz>B</Paz> <Paz>B</Paz></StatussR>HOW to declare it in Schema ?Also, is there any possibility how to define the Exact order of the <PAZ> should have? Alphabeticaly or some other? Link to comment Share on other sites More sharing options...
Aruna Posted December 15, 2009 Share Posted December 15, 2009 We have a keyword called xs:key in XML Schema to define unique elements that are not null. This will ensure that values are not repeated and that they are unique. To use xs:key we need to understand xs:selector and xs:field.If you would like to define a unique element that can be null it could be done using xs:unique keyword.For knowing more please refer to my article at http://technologyandleadership.com/xml-sch...y-and-xskeyref/ Link to comment Share on other sites More sharing options...
tipone Posted December 15, 2009 Author Share Posted December 15, 2009 Thank you for your answer! Looks hard, but enivey it is a solution Link to comment Share on other sites More sharing options...
Aruna Posted December 24, 2009 Share Posted December 24, 2009 Hey its not hard. It is very easy. If you try this code it will not allow repeating values for Paz: <?xml version="1.0" encoding="UTF-8"?><xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="StatussR"> <xs:complexType> <xs:sequence> <xs:element name="Paz" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:key name="keyPAZ"> <xs:selector xpath="StatussR"/> <xs:field xpath="Paz"/> </xs:key> </xs:element></xs:schema> Thank you for your answer! Looks hard, but enivey it is a solution Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.