I guess that you read the second edition of Mike's book, in which he covered
XSLT 1.1.
XSLT 1.1 was never developed by the W3C into a final status and is not a
standard. The current standard of XSLT 1.0 has the concept of RTF (Result
Tree Fragment).
An RTF cannot be treated like a node-set in XPath -- any such attempt
results in raising an error -- this is exactly what you described.
In order to process an RTF as a node-set, one must use an
implementation-defined extension function with the usual name of node-set(),
belonging to an implementation-dependent namespace, or use the
common:node-set() function as defined by EXSLT.
These functions take an RTF and convert it to a regular node-set. Then their
result is a regular tree (a node-set having just one root node) and can be
navigated using XPath.
Therefore, you also have to use whatever implementation-defined
xxx:node-set() extension function is available for your XSLT processor.
Cheers,
Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,
http://fxsl.sourceforge.net/ -- the home of FXSL
Resume:
http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Justine Hlista" <jb**************@yahoo.com> wrote in message
news:3e**************************@posting.google.c om...
I'm using xalan-j_2_6_0 and trying to get an example from Michael
Kay's book to work:
<xsl:template match="/">
<xsl:variable name="rainbow">
<color>red</color>
<color>blue</color>
<color>green</color>
</xsl:variable>
<xsl:for-each select="$rainbow/color">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
Both XSLTC and XSLT generate errors when they encounter the XPath
expression in the select attribute. I cannot get XSLTC or XSLT to
accept any expression that qualifies a variable in a select statement.
Am I trying to do something that is strictly forbidden here? Am I
misunderstanding what Michael Kay's example was supposed to do?
Any help is greatly appreciated!!
Justine