Question

I'd like to use the assert feature of XSD 1.1 using QXmlSchema.

If tested it with the following xsd:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="root">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="node1">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:integer">
                        <xsd:minInclusive value="0"/>
                        <xsd:maxInclusive value="100"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="node2">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="x" type="xsd:int"/>
                        <xsd:element name="y" type="xsd:int"/>
                    </xsd:sequence>
                    <xsd:assert test="x+ y=0"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

and the following xml:

<root>
    <node1>1</node1>
    <node2>
          <x>1</x>
          <y>3</y>
    </node2>
</root>

Now, the following code snippet returns valid schema and xml data, even though the assert should be false.

 QXmlSchema schema;
 schema.load(schemaData);
 schema.isValid(); // true <=====
 QXmlSchemaValidator validator(schema);
 validator.validate(xmlData)); //true <=====

Any idea why? Is it because Xsd 1.1 is not implemented in Qt? If so, why is the schema considered to be valid?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top