XSD 1.1 Asserts Implementation Dependent Result

Consider the following simple diagram with a simple statement:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">
    <xs:element name="root">
        <xs:complexType>
            <xs:assert test="(8 = 8) or name('error')"></xs:assert>
        </xs:complexType>
    </xs:element>
</xs:schema>

      

Let's look at the statement:

(8 = 8) or name('error')

      

The left operand is true and the second is an error if evaluated (since the name functions expect a node parameter, not a string). The Saxon validator says the assertion is fulfilled, the Xerces validator says it is not .

According to XPath 1.0 specification

The operator on the right is not evaluated if the left operand evaluates to true

Thus, according to XPath 1.0, this assertion should be performed without raising the error, since the right-hand operand should not be evaluated. However, XSD 1.1 uses XPath 2.0, which provides an implementation-dependent order of evaluation, states :

If XPath 1.0 compatibility mode is false [...], the or-expression can return true if the first expression evaluated is true, and it can throw an error if evaluating the first expression produces an error [...]. Boolean expression is not deterministic in the presence of Error

In the XSD 1.1 spec, we can clearly read:

In order for the Xath Expression X property record to be valid, all of the following values ​​must be true :

[...]

2.2.1 XPath 1.0 compatibility mode is false.

[...]

So, as I understand it, in XSD 1.1 the XPath compatibility mode is false, so the result of the assertion is implementation dependent, so the XML document must be valid against the same XSD depending on the validator implementation . In this case, Saxon is correct in asserting that the assertion is satisfied, and Xerces is also correct in stating that this assertion is not satisfied. Is this correct or am I missing something?

+3


source to share


1 answer


Yes you are right. If you want (A or B) where A is guaranteed to evaluate to B, you can write test="if (A) then true() else B"

.



+3


source







All Articles