Subject: RE: Use of xsl:document
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 22 Jun 2006 12:27:03 +0100
|
> I wish to store an external XML file as the value of an XSLT
> variable using XSLT 2.0. This is how it is presently being acheived:
>
> <xsl:variable name="Xml" as="document-node()"
> select="document('test.xml')"/>
That's the correct way to do it.
>
> Should I be using the xsl:document function instead?
> If I should, why?
> Is there any use for the xsl:document function other than the
> fact it allows validation?
xsl:document is an instruction, not a function. It allows you to construct a
document within the stylesheet, rather than reading an external file such as
text.xml.
You can construct a document implicitly using
<xsl:variable name="x">
<test>
<data/>
</test>
</xsl:variable>
Using xsl:document makes this more explicit and provides access to extra
functionality such as validation.
Michael Kay
http://www.saxonica.com/
|