[
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: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
|