Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4678419

uniqueness violation isn't detected

XMLWordPrintable

    • 1.3
    • generic
    • generic

        Name: erR10175 Date: 05/01/2002


          New JAXP TCK 1.2 test
        api/xml_schema/structures/IdConstrDefs/fields/fields002/fields00203m/fields00203m2.html#Negative
         
        fails because xerces doesn't detect identity constraint violation in
        the document below.

        In the test the both fields have local type decimal and values "3.0" and "3".
        While the lexical representations differ, the values are equal. So the
        uniqueness constraint is violated and the test expects the validator to
        report the error.
         

        The specification (XML Schema Part 1: Structures,
        3.11.1 The Identity-constraint Definition Schema Component) reads:
        "The equality and inequality conditions appealed to in checking these
        constraints apply to the value of the fields selected, so that for example
        3.0 and 3 would be conflicting keys if they were both number, but
        non-conflicting if they were both strings, or one was a string and
        one a number."

        Note then if type of the field "number" in element declaration is
        specified as "xsd:decimal" instead of "xsd:anySimpleType"
        the violation is detected.

        The test's schema is:
        -------------------------- fields00203m2.xsd
        <?xml version="1.0"?>
        <xsd:schema
          xmlns="IdConstrDefs/fields"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          targetNamespace="IdConstrDefs/fields">
          <xsd:element name="root">
              <xsd:complexType>
                  <xsd:sequence maxOccurs="unbounded">
                      <xsd:element name="number" type="xsd:anySimpleType"/>
                  </xsd:sequence>
              </xsd:complexType>
              <xsd:unique name="UNIQUENESS">
                  <xsd:selector xpath="./number"/>
                  <xsd:field xpath="."/>
              </xsd:unique>
          </xsd:element>
        </xsd:schema>
        --------------------------

        The invalid document is:
        -------------------------- fields00203m2_n.xml
        <?xml version="1.0"?>
        <test:root
          xmlns:test="IdConstrDefs/fields"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xsi:schemaLocation="IdConstrDefs/fields fields00203m2.xsd">
          <number xsi:type="xsd:decimal">3.0</number>
          <number xsi:type="xsd:decimal">3</number>
        </test:root>
        --------------------------

        ======================================================================

              kkawagucsunw Kohsuke Kawaguchi (Inactive)
              reysunw Rey Rey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: