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>

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>

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>

Xerces-C 2.8: "Field matches more than one value within the scope of its selector" and "Duplicate unique value declared"
Xerces-C 3.0: Valid

As far as I can tell there seems to be at least two separate bugs here - namespaces in the XPath selector and field aren't handled correctly, and a separate problem with not checking unique constraints correctly.

Can anyone comment on what might be going on here?

John

--
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:        http://www.oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net
<?xml version="1.0" encoding="UTF-8"?>
<cars xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://www.example.com/4.xsd foo.xsd"
    xmlns="http://www.example.com/4.xsd";>
  <car vin="1"/>
  <car vin="1"/>
</cars>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    targetNamespace="http://www.example.com/4.xsd";
    xmlns="http://www.example.com/4.xsd";
    xmlns:ns="http://www.example.com/4.xsd";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">
  <xs:element name="cars">
    <xs:complexType>
      <xs:sequence maxOccurs="unbounded">
        <xs:element name="car">
          <xs:complexType>
            <xs:attribute name="vin"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="vinUnique">
      <xs:selector xpath="ns:car"/>
      <xs:field xpath="@vin"/>
    </xs:unique>
  </xs:element>
</xs:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to