I've been testing Xerces with some schemas 1.1, more specifically, those
with assertions. Xerces do not complain when I use a valid XML with a given
Schema. However, if I use an invalid XML, it doesn't complain either. I
used many samples, but I will show a simple case.

Below is a simple Schema 1.1.

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema";
        elementFormDefault="qualified">

    <element name="Example">
        <complexType>
            <sequence>
                <element name="even-integer">
                    <simpleType>
                        <restriction base="integer">
                            <assertion test="$value mod 2 = 0" />
                        </restriction>
                    </simpleType>
                </element>
            </sequence>
        </complexType>
    </element>

</schema>

I tested the following XML using the schema above:

<?xml version="1.0" encoding="utf-8"?>
<Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:noNamespaceSchemaLocation="even-integers_v1.xsd">

    <even-integer>21</even-integer>

</Example>

To test this, I'm instantiating an SchemaFactory using the following line:
schemaFactory = SchemaFactory.newInstance("
http://www.w3.org/XML/XMLSchema/v1.1";);

So, I'm using the Schema 1.1 in my code, and the parser doesn't generate
any error when it parses the XML above, using the above schema. In Xerces
main page, it says assertions are supported, so I believe I may be doing
something wrong, but I haven't been able to find the mistake. Do you have
any suggestions ?

Thanks,
            Vinícius

Reply via email to