469,352 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Unique costraint in XML Schema

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?


Jul 20 '05 #1
7 7499


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.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
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.

--


Could you give me an example?
Jul 20 '05 #3
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.
Jul 20 '05 #4
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

-----------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema (Prentice Hall PTR)
http://www.datypic.com
-----------------------------------------------------

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5


hyppos wrote:
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.


No, a type can't be unique, only an element or attribute in a certain
scope, see the example in
http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #6
Martin Honnen <ma*******@yahoo.de> writes:
No, a type can't be unique, only an element or attribute in a certain
scope, see the example in
http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness


The advice is good, but there are a few glitches in the original
version of the Primer -- a better reference is the draft 2nd edition
at

http://www.w3.org/TR/2004/PER-xmlsch...yingUniqueness

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #7

Thks to Everybody
Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Victor Engmark | last post: by
1 post views Thread by cedric.louyot | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.