[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xs:unique question

From: Andrew Welch <andrew.j.welch@gmail.com>
Date: Wed, 14 Feb 2007 14:59:42 +0000
Message-ID: <74a894af0702140659t51a3348bu34bda68c5873790a@mail.gmail.com>
To: "Markus Gamperl" <markus.gamperl@gmx.at>
Cc: xmlschema-dev@w3.org
Re: xs:unique question

On 2/14/07, Markus Gamperl <markus.gamperl@gmx.at> wrote:
>
> Hi.
>
> I have defined the following complex type with a unique:
>
> <xs:complexType name="root">
>  <xs:sequence>
>   <xs:element name="name" type="xs:string"/>
>   <xs:element name="daten" nillable="true">
>    <xs:complexType>
>     <xs:sequence>
>      <xs:element name="preiszeile">
>        <xs:complexType>
>         <xs:sequence maxOccurs="unbounded">
>         <xs:element name="zweig" type="xs:integer"/>
>         <xs:element name="herkunft" type="xs:integer"/>
>         <xs:element name="anzahlen" type="xs:string"/>
>      </xs:sequence>
>     </xs:complexType>
>    </xs:element>
>   </xs:sequence>
>  </xs:complexType>
>  <xs:unique name="uniquepreis">
>   <xs:selector xpath="preiszeile"/>
>   <xs:field xpath="zweig"/>
>   <xs:field xpath="herkunft"/>
>  </xs:unique>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
> example for a xml file:
> <root>
>  <name>76</name>
>   <daten>
>    <preiszeile>
>         <zweig>11</zweig>
>         <herkunft>0</herkunft>
>         <anzahlen>test</anzahlen>
>    </preiszeile>
>    <preiszeile>
>         <zweig>11</zweig>
>         <herkunft>0</herkunft>
>         <anzahlen>test</anzahlen>
>    </preiszeile>
>    <preiszeile>
>         <zweig>11</zweig>
>         <herkunft>0</herkunft>
>         <anzahlen>test</anzahlen>
>    </preiszeile>
>    ...
>   </daten>
> </root>
>
> I want a unique key over all zweig + herkunft elements.
> Therefore I used xs:unique but it don't work...


You appear to have put maxOccurs="unbounded" on the wrong xs:sequence
- you need to put on the sequence defining the <preiszeile> children
of <daten>, according to your example input.


cheers
andrew
Received on Wednesday, 14 February 2007 14:59:48 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.