Re: [xsl] Dynamicaly applying templates from a node-set containing xpath values - with msxml parser

Subject: Re: [xsl] Dynamicaly applying templates from a node-set containing xpath values - with msxml parser
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Thu, 27 Oct 2005 23:37:25 +0200
Hi again Matthieu,

I have been rereading your mail here, and have a couple of thoughts.

On 10/26/05, Matthieu Ricaud <matthieu.ricaud@xxxxxxx> wrote:
> Thank you for your answer Ragulf !
> I tried :
> <xsl:for-each select="msxsl:node-set($NodeSetXpathNode)/xpath">
>  <xsl:variable name="var" select="'/foo/@bar'"/>
>  <xsl:value-of select="dyn:evaluate(.,$var)"/>
> </xsl:for-each>
> I do not get error message anymore, but unfortunately the template is not
> applied.

Here, I think the problem is, that you are not in the domain of the
document, but rather of the nodeset (contained in
msxsl:node-set($NodeSetXpathNode)/xpath). I think you will have to
shift the contents to the document. Perhaps something link
dyn:evaluate($root,$var)"/> where $root is the root element in the
input document (<xsl:variable name="root" select="/">).

If this works, then the same applies to your real problem.

> and that's it ! I don't get error anymore with this code.
> (actually I don't really see why... maybe select="." select a text node,
> which is not considered as a string ?)

The select="." does not select a text() node, but rather the current
node, which will be the different xpath elements in the nodeset.
Therefore there is a vast difference of writing:
<xsl:variable name="foo" select="'bar'"/> <!-- String with value "bar" -->
<xsl:variable name="foo" select="bar"/> <!-- Element called "bar" -->
That you have when you say select="." is essentially the same as the
latter of the two. Therefore the string conversion is needed.

> Within the node-set iteration, "." represents the iterated node and not any
> node of the xml tree.
> Is there a way, within the iteration, to come back to another context node,
> the root of the xml file for example ?

See first part of mail.

I hope this is of some help
Ragulf Pickaxe :-)

Current Thread