Validation in 3.7.3.3 Document Node Constructors

Section 3.7.3.3 of the XQuery specification says that for
document constructors, "No schema validation is performed on the
constructed document." This seems inconsistent with implicit  
validation of elements. Consider the following element
constructor.

<person>
   {
      $that/name,
      $that/address,
      $that/shoesize
   }
</person>

If the person element is in the ISSD, this is validated. Now observe
what happens if this element is placed in a document node.

document
{
  <person>
    {
      $that/name,
      $that/address,
      $that/shoesize
    }
  </person>
}

Under the current language definition, the &lt;person>
element would be validated by its own constructor, and an error
would be raised if validation fails. Then the validated
<person> element would be copied under a new document node and
its type annotation would be changed to xdt:untyped. If element
constructors are implicitly validated, users will expect elements
in document nodes to be valid. Two possibilities seem
reasonable:

1. Copy the content directly to the document node
    constructor, preserving the types of child elements. This is
    simpler, but does not enforce identity
    constraints.

2. Copy the content directly to the document node
    constructor, preserving the types of child elements, then apply
    identity constraints to the document. This adds complexity, but
    ensures that the resulting document is schema valid.

The status quo does not seem reasonable.

Jonathan

Received on Tuesday, 10 February 2004 16:57:21 UTC