You need to explicitly turn on the identity constrain checking

dc->setParameter(XMLUni::fgXercesIdentityConstraintChecking, true);

Alberto

David Lowndes wrote:
I have the following xsd snippets:

        <xs:element name="Operations" type="OperationsType">
          <xs:unique name="NoDuplicateOperations">
            <xs:selector xpath="Operation" />
            <xs:field xpath="." />
          </xs:unique>
        </xs:element>

  <xs:complexType name="OperationsType" >
    <xs:sequence>
<xs:element name="Operation" type="OperationType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="OperationType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Item1" />
      <xs:enumeration value="Item2" />
    ... other values
    </xs:restriction>
  </xs:simpleType>

and in the XML file an error (Item1 is duplicated):

    <Operations>
        <Operation>Item1</Operation>
        <Operation>Item1</Operation>
        ... other properly unique items
    </Operations>
If I view the XML/XSD files in Visual Studio it correctly flags the non-unique element. However xerces (V3) doesn't appear to generate any errors for it with the following code:

DOMConfiguration* dc = m_parser->getDomConfig();
dc->setParameter(XMLUni::fgDOMValidate, true);
dc->setParameter(XMLUni::fgDOMNamespaces, true);
dc->setParameter(XMLUni::fgXercesSchema, true);
dc->setParameter(XMLUni::fgDOMValidateIfSchema, true);
MyDOMErrorHandler myErrorHandler;
dc->setParameter(XMLUni::fgDOMErrorHandler, &myErrorHandler);
m_XMLdoc = m_parser->parseURI( MyXMLFileName );

Is there some other optional parameter I may need to set to get xerces V3 to catch this error - or doesn't it currently support "unique"?

Dave Lowndes



Reply via email to