Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1729

Simple unique constraint fails across choice element

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Duplicate
    • 1.5, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0, 2.6.0, 2.7.0
    • 2.7.0
    • None
    • UNBUNTU 7.04 Intel
      g++ 4.01

    Description

      Error while parsing xml- check against schema:
      Failed to parse: Not enough values specified for <unique> identity constraint for element 'Pairs'.

      The problem occurs in 'UniqueDirectionStartObj1AcrossFile' where i ask that the direction with the StartObj1 is unique across the file. StartObj1 is part of a choice element where the choice is StartObj1 or StartObj2. When StartObj2 exists instead of StartObj1 Xerces complains that there are not enough values for the unique contraint. This is the problem.

      I would expect the code to say " there's no StartObj1 in this case so the unique contraint doesn't apply, lets skip it in the case' but the code complains that the hasn't got the values to complete the unique case.

      If its not there don't apply the constraint!!!

      XMLSpy handles this as i would expect.

      the data...

      <Pairs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TEST.xsd">
      <Pair>
      <Direction>UP</Direction>
      <Start>
      <StartObj1>20</StartObj1>
      </Start>
      </Pair>
      <Pair>
      <Direction>UP</Direction>
      <Start>
      <StartObj2>30</StartObj2>
      </Start>
      </Pair>
      </Pairs>

      the schema...

      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
      <xs:element name="Pairs">
      <xs:annotation>
      <xs:documentation>Comment describing your root element</xs:documentation>
      </xs:annotation>
      <xs:complexType>
      <xs:sequence>
      <xs:element name="Pair" maxOccurs="unbounded">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="Direction"/>
      <xs:element name="Start">
      <xs:complexType>
      <xs:choice>
      <xs:element name="StartObj1"/>
      <xs:element name="StartObj2"/>
      </xs:choice>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      <xs:unique name="UniqueDirectionStartObj1AcrossFile">
      <xs:selector xpath="Pair"/>
      <xs:field xpath="Direction"/>
      <xs:field xpath="Start/StartObj1"/>
      </xs:unique>
      </xs:element>
      </xs:schema>

      Attachments

        Activity

          People

            Unassigned Unassigned
            sgbaker Steve Baker
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: