OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



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

[ Lists Home | Date Index | Thread Index ]

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

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

<!-- 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:element name="presentation" maxOccurs="unbounded">
             : more elements snipped
            <xs:element ref="ind:price" minOccurs="0" maxOccurs="4"/>
             : more elements snipped
        <xs:unique name="uniqueindprice">
          <xs:selector xpath="ind:price"/>
          <xs:field xpath="@type"/>
            : more unique constraints snipped

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?

Ola Strandberg, Cut! Consulting

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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS