John Snelson wrote:
Hi everyone,
One of our users is having an issue with a unique constraint in his
schema. I've attached an example XML document and XML Schema file. Both
XML Spy and Visual Studio confirm that the XML document breaks the
uniqueness constraint, but Xerces-C does not detect this. I've tested
this and various permutations with both Xerces-C 2.8 and 3.0, and if
anything 3.0 seems more broken:
1)
<xs:unique name="vinUnique">
<xs:selector xpath="ns:car"/>
<xs:field xpath="@vin"/>
</xs:unique>
Xerces-C 2.8: Valid
Xerces-C 3.0: Valid
2)
<xs:unique name="vinUnique">
<xs:selector xpath="*:car"/>
<xs:field xpath="@vin"/>
</xs:unique>
This is an invalid expression according to the schema recommendation. The
namespace part of the QName is not allowed to be wildcard. See:
http://www.w3.org/TR/xmlschema-1/#NameTest
Xerces-C 2.8: Valid
Xerces-C 3.0: Valid
3)
<xs:unique name="vinUnique">
<xs:selector xpath="ns:car/@vin"/>
<xs:field xpath="."/>
</xs:unique>
Xerces-C 2.8: "Selectors cannot select attributes"
Xerces-C 3.0: "Selectors cannot select attributes"
4)
<xs:unique name="vinUnique">
<xs:selector xpath="*:car/@vin"/>
<xs:field xpath="."/>
</xs:unique>
Again, this is an invalid XPath expression.
Xerces-C 2.8: "Duplicate unique value declared"
Xerces-C 3.0: Valid
5)
<xs:unique name="vinUnique">
<xs:selector xpath="."/>
<xs:field xpath="ns:car/@vin"/>
</xs:unique>
Xerces-C 2.8: Valid
Xerces-C 3.0: Valid
6)
<xs:unique name="vinUnique">
<xs:selector xpath="."/>
<xs:field xpath="*:car/@vin"/>
</xs:unique>
Again, this is an invalid XPath expression.
Xerces-J reports the following:
V:\test\snelson>java sax.Writer -n -v -s foo.xml
<?xml version="1.0" encoding="UTF-8"?>
<cars xsi:schemaLocation="http://www.example.com/4.xsd foo.xsd">
<car vin="1"></car>
[Error] foo.xml:6:17: cvc-identity-constraint.4.1: Duplicate unique
value [1]
declared for identity constraint "vinUnique" of element "cars".
<car vin="1"></car>
</cars>
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]