data.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="myxslt2.xslt"?>
<data>
<foo>Hello</foo>
<bar>World</bar>
<foobar>This is a test</foobar>
</data>
myxslt2.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" version="1.0">
<xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/>
<xsl:variable name="main" select="/data"/>
<xsl:template name="myTemplate">
<xsl:param name="myparam"/>
Inner1:<xsl:value-of select="msxsl:node-set($myparam)"/>
<br/>
Inner2:<xsl:value-of select="msxsl:node-set($myparam)/foobar"/>
</xsl:template>
<xsl:template match="/data">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
HTML STARTS
<br/>
<xsl:variable name="data" select="."/>
Outer1:<xsl:value-of select="$data"/>
<br/>
Outer2:<xsl:value-of select="$data/foobar"/>
<br/>
<xsl:call-template name="myTemplate">
<xsl:with-param name="myparam">
<xsl:value-of select="$data"/>
</xsl:with-param>
</xsl:call-template>
</html>
</xsl:template>
</xsl:stylesheet>
Output:
HTML STARTS
Outer1: Hello World This is a test
Outer2:This is a test
Inner1: Hello World This is a test
Inner2:
Can someone explain why the inner doesn't resolve the subelement while the outer does?