# xsl:document

The `xsl:document` instruction creates a new document node. The content of the new document node is created using the contained instructions (in the same way as `xsl:result-document`), and the new document node is added to the result sequence. The instruction is useful mainly if you want to validate the document: the element allows attributes `validation` and `type` which perform document-level validation in the same way as the corresponding attributes on `xsl:result-document`.

The instruction also allows a function or template to create a temporary tree without the need to create a variable and then return the value of the variable.

The instruction has been added during the last call phase, it was not included in the 12 Nov 2003 draft specification. It should not be confused with the instruction of the same name in the XSLT 1.1 draft, which was a precursor to `xsl:result-document`.

Expand | Next