In XSLT 1.0, a variable defined as in your example is called a result tree fragment (RTF), and you can use xsl:copy-of to copy the entire fragment to the resulting tree or xsl:value-of to copy the entire contents. Example
<xsl:copy-of select="$LANG"/>
If you want to treat the variable as a temporary tree, you will need the extension node-set() .
A common way to handle static tree fragments (for example, lookup tables) in XSLT 1.0 is to define them as children of the root elements of the stylesheet (using a custom namespace). Then you can use the document() function to get the required value.
Note If you use Saxon (v> 6.5), you can simply install the stylesheet version 1.1 and you can manage RTF without any node -set extension.
[XSLT 1.0]
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:empo="http://stackoverflow.com/users/253811/empo"> <empo:LANG> <empo:foo> <empo:bar>Hello</empo:bar> </empo:foo> </empo:LANG> <xsl:template match="/"> <xsl:variable name="LANG" select="document('')/*/empo:LANG"/> <xsl:value-of select="$LANG/empo:foo/empo:bar"/> </xsl:template> </xsl:stylesheet>
Emiliano poggi
source share