[
Lists Home |
Date Index |
Thread Index
]
Hello all,
I noticed three different behaviours with three different xml parsers with
the <xsd:unique> element. Can somebody give me an indication of which is the
right one.
xsd file:
<xsd:schema xmlns:ipm="http://unique/test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://unique/test"
elementFormDefault="qualified">
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="ipm:mayHaveDaughter" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:unique name="uniqueNode">
<xsd:selector xpath="ipm:mayHaveDaughter"/>
<xsd:field xpath="@f1"/>
<xsd:field xpath="ipm:d"/>
</xsd:unique>
</xsd:element>
<xsd:element name="mayHaveDaughter">
<xsd:complexType>
<xsd:choice>
<xsd:element name="d" minOccurs="0" maxOccurs="1"
type="xsd:string"/>
</xsd:choice>
<xsd:attribute name="f1" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
example xml file:
<?xml version="1.0"?>
<root xmlns="http://unique/test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://unique/test unique.xsd">
<mayHaveDaughter f1="a"/>
<mayHaveDaughter f1="b"/>
<mayHaveDaughter f1="c">
<s>1</s>
</mayHaveDaughter>
<mayHaveDaughter f1="c">
<s>2</s>
</mayHaveDaughter>
</root>
What should be the behaviour when the optional tag <d> is missing. Both
MSXML 4.0 and xsdvalid still check on the f1 attribute. So if we leave out
the <d> tags in the example the file is invalid, because there are two
<mayHaveDaughter> elements with a f1 attribute value 'c'. However with xsv
no error is generated, and with XercesJ-2.3.0 I get following error: 'Not
enough values specified for <unique> identity constraint specified for
element'.
So my question is, if one of the optional elements is not available, should
this element be ignored or not. The recs seems to be not clear about that.
Kind regards,
Ismaël
|