Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Unique costraint in XML Schema

Reply
Thread Tools

Unique costraint in XML Schema

 
 
hyppos
Guest
Posts: n/a
 
      07-07-2004
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?




 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-07-2004


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/

 
Reply With Quote
 
 
 
 
hyppos
Guest
Posts: n/a
 
      07-07-2004

> > 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?


 
Reply With Quote
 
hyppos
Guest
Posts: n/a
 
      07-07-2004

> 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.


 
Reply With Quote
 
Priscilla Walmsley
Guest
Posts: n/a
 
      07-07-2004
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!
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      07-07-2004


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/

 
Reply With Quote
 
Henry S. Thompson
Guest
Posts: n/a
 
      07-08-2004
Martin Honnen <(E-Mail Removed)> 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: http://www.velocityreviews.com/forums/(E-Mail Removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
Reply With Quote
 
hyppos
Guest
Posts: n/a
 
      07-09-2004

Thks to Everybody


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema huntingseasonson@gmail.com Perl Misc 5 11-29-2006 12:37 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML Schema to XML Schema Conversion Hari Om XML 1 03-02-2004 09:04 PM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM



Advertisments