Unique costraint in XML Schema

hyppos

Usenet Archive
Joined
Jul 7, 2004
Messages
4
Reaction score
0
Hi,
I've a XML Schema with this user Type

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

How can I add an unique costraint to this type?
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
hyppos wrote:

I've a XML Schema with this user Type

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

How can I add an unique costraint to this type?

You can use <xsd:unique> at the place where you use this type for an element definition I think.
 

hyppos

Usenet Archive
Joined
Jul 7, 2004
Messages
4
Reaction score
0
You can use <xsd:unique> at the place where you use this type for an element definition I think.
Like This?

<xsd:simpleType name="ResultArrayType">
<xsd:restriction base="xsd:unique">
<xsd:maxExclusive value="1000"/>
</xsd:restriction>
</xsd:simpleType>

unfortunately, doesn't work.
 

Priscilla Walmsley

Usenet Archive
Joined
Apr 15, 2004
Messages
77
Reaction score
0
Hi,

You specify the uniqueness constraint on the element, not the type. For example, if you had an element named "Number" with that type, and you wanted its value to be unique within the scope of its parent element "listOfNumbers", it would look something like this:

<xs:element name="listOfNumbers">
<xs:complexType>
<xs:sequence>
<xs:element name="Number" type="ResultArrayType"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueNum">
<xs:selector xpath="Number"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>

Hope that helps,
Priscilla
 

Henry S. Thompson

Usenet Archive
Joined
Jan 14, 2000
Messages
309
Reaction score
0

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top