[XSLT 2.0] Validating document nodes

I raised this proposal originally on the XSL WG internal list. The WG
accepted the proposal in principle, and actioned me to raise it as a
public comment to give visibility and allow comments on the proposal.

The original proposal is at
http://lists.w3.org/Archives/Member/w3c-xsl-wg/2004Jan/0008.html
(members only).

The proposal (as modified by the WG) is:

There are two situations in which we apply document-level validation
(which includes checking of constraints such as unique/key/keyref): when
creating a document using xsl:result-document, and when copying a
document using xsl:copy or xsl:copy-of.

This means that if you want to check document level constraints on a
temporary tree, the only way to do it is to create the temporary tree
without validation, and then copy it with validation. This seems clumsy
and artificial, and it means that any validation errors can't be located
to the line in the stylesheet that wrote the erroneous data.

So I think we should have a way of creating a temporary tree with
document-level validation.

The question is, what should the syntax look like? xsl:variable and its
friends are complicated enough already, so adding validation and type
attributes here doesn't seem a good idea.

I suggest we introduce a new instruction xsl:document to create a
document node. We give it attributes "validation" and "type" that behave
like the corresponding attributes on xsl:result-document. The semantics
of the new instruction are the same as the semantics of <xsl:copy> in
the case where the context item is a document node.

<xsl:variable>
  xxx
</xsl:variable> 

can now be explained as shorthand for

<xsl:variable as="document-node()">
  <xsl:document>
    xxx
  </xsl:document>
</xsl:variable>

If you want document-level validation on the temporary tree, you have to
use the expanded syntax, and put a validation and/or type attribute on
the xsl:document element.

Michael Kay

Received on Sunday, 25 January 2004 16:48:18 UTC