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: "Matthieu Ricaud" <matthieu.ricaud@xxxxxxx>
Date: Fri, 28 Oct 2005 11:21:26 +0200
Hi Ragulf,
the <xsl:value-of select="dyn:evaluate($root,$var)"/> with <xsl:variable
name="root" select="/">
works perfectly, in my real problem also !
It looks so obvious now you said it !
Thanks a lot for this good "couple of thoughts" and your explanation,
Have a nice day,
cheers,
Matthieu.

-----Message d'origine-----
De : Ragulf Pickaxe [mailto:ragulf.pickaxe@xxxxxxxxx]
Envoyi : jeudi 27 octobre 2005 23:37
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Objet : Re: [xsl] Dynamicaly applying templates from a node-set
containing xpath values - with msxml parser


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