>Using the latest xalan (don't know about the behaviour in previous
>versions) I cannot wrap an xsl:for-each as a variable e.g. <xsl:variable
>name="test"><xsl:for-each ......etc... ></xsl:for-each></xsl:variable> I
>get a 'cannot convert tree fragment to node-list exception'.

>However, if I put the 'for each' in a template I can wrap the return from
>this template in a variable.


I haven't worked it through in detail, but I _think_ you're getting burned by a subtle distinction between a Result Tree Fragment and a nodeset containing the root node of an RTF. The latter can be assigned directly to a variable; the former can't be.

Xalan does have a nodeset() extension function, which will wrap a nodeset around values which aren't nodesets (or aren't even nodes)... but I'm not sure I see a good way to apply it to your case. Doing the call-template may indeed be the simplest and most portable answer in XSLT 1.0.


XSLT 2.0 allows Temporary Trees (new name for RTFs) to be treated directly as nodesets, but we can't do that in a fully compliant 1.0 implementation.

______________________________________
Joe Kesselman / IBM Research

Reply via email to