[XQuery] Semantics of validation context

I am having trouble understanding the meaning of the validation context
which may be specified in a validate expression (and equally, the
implicit validation context used when validating element constructors)

This seems to be specified largely by example. One of the examples is:

Suppose that $x is bound to a shipTo element. Then validate strict
context po:purchaseOrder {$x} validates the value of $x in strict mode,
in the context of the top-level element declaration po:purchaseOrder.

So what happens if the element declaration po:purchaseOrder has the
content model:

<xs:sequence>
 <xs:any namespace="##any" processContents="skip">
</xs:sequence>

Is the shipTo element valid here? I would hope that it is, because the
schema says it is allowed as a child of purchaseOrder, and it seems
wrong that we should be able to create a structure that fails validation
even though it conforms to the schema. But the specification suggests
otherwise: "strict requires that each element to be validated must be
present in the in-scope element declarations,...". 

So, perhaps there is a global element declaration for shipTo. Does this
affect the outcome? Am I allowed to use the global element declaration,
even though the context path for validation specifies some local
declaration? It would be very strange if this were the case, but that's
what the text seems to suggest.

But now read it again. The "in-scope element declarations" does not
contain elements, it contains element declarations. What does it mean
for "the element to be validated" to be "present in the in-scope element
declarations"? Section 2.1.1.1 says "Each element declaration is
identified either by a QName (for a top-level element declaration) or by
an implementation-dependent element identifier (for a local element
declaration)". But the section on validation seems to be assuming
otherwise: it seems to assume that an element declaration is identified
not by a QName, but by some kind of path. Of course an element
declaration that's contained in a group, or that's referred to be an
<xs:element ref="xx"> can be reached by many different paths (an
infinite number of paths). Are these paths allowed to contain wildcards
or not?

I'll stop there. Perhaps this is all clarified in the formal semantics?

XSLT 2.0, incidentally, avoids these problems. It does not allow
validation against anything other than a global element declaration or a
global type.

Michael Kay

Received on Friday, 16 January 2004 18:09:23 UTC