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

Problem with scope of <unique> in .NET XML schema classes?

  • To: xml-dev@l...
  • Subject: Problem with scope of <unique> in .NET XML schema classes?
  • From: "Ola Strandberg" <strandberg_ola@h...>
  • Date: Sat, 02 Nov 2002 10:18:23 +0100
  • Bcc:

xs unique
Hi All,
I have a schema that contains the following:

<!-- definition of the price element in the "ind" namespace -->
<xs:element name="price">
  <xs:complexType>
    <xs:sequence>
      <xs:group ref="util:auditElems" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="type" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="pricetype1"/>
          <xs:enumeration value="pricetype2"/>
          <xs:enumeration value="pricetype3"/>
          <xs:enumeration value="pricetype4"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="v" type="xs:decimal" use="optional"/>
  </xs:complexType>
</xs:element>

<!-- in a container element, I have a child called typeofpack,
which in turn may have many presentations. For each presentation,
I want them to have a unique set of prices. -->
<xs:element name="typeofpack">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="presentation" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
             : more elements snipped
            <xs:element ref="ind:price" minOccurs="0" maxOccurs="4"/>
             : more elements snipped
          </xs:sequence>
        </xs:complexType>
        <xs:unique name="uniqueindprice">
          <xs:selector xpath="ind:price"/>
          <xs:field xpath="@type"/>
        </xs:unique>
            : more unique constraints snipped
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

Now, in XMLSPY, this works as expected regardless of the number of 
presentation elements. As long as there are only one of each ind:price/@type 
occurences it works.

The problem arises when I validate this with an XMLValidatingReader from the 
.NET framework. It seems that it disregards the scope of the unique 
constraint (which should be *within* each presentation element) and 
complains when there are occurences of the same ind:price/@type across the 
*whole document*.

"There is a duplicate key sequence 'pricetype1' for '<urn>:uniqueindprice' 
key or unique identity constraint.  An error occurred at 
file:///<path>/test.xml(715, 7)"

Any ideas?

Cheers,
Ola Strandberg, Cut! Consulting




_________________________________________________________________
Hela veckans väder  http://www.msn.se/vader


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.