# 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.

This instruction should not be confused with the instruction of the same name in the XSLT 1.1 draft, (which is supported in Saxon 6.5.x). That instruction was a precursor to `xsl:result-document`.

Next