Subject: [xsl] Dynamicaly applying templates from a node-set containing xpath values - with msxml parser From: "Matthieu Ricaud" <matthieu.ricaud@xxxxxxx> Date: Tue, 25 Oct 2005 22:50:29 +0200 |
Hello, I'm using msxml, which has no evaluate() function. So I use a javascript extension fonction to it with the namespace xmlns:dyn="http://exslt.org/dynamic" found at http://www.xmleverywhere.com/tips/xslt.htm . Example of use : im my xml /foo/@bar has the value "hello" in my xsl i do : <xsl:variable name="var" select="'/foo/@bar'"/> <xsl:value-of select="dyn:evaluate(.,$var)"/> I get "hello" as result. (I wrote "absolute" xpath in this example so that the context doesn't matter) I often use this without problems (as well for applying template) but this time i have one... This time the variable to be evaluated is extracted from a node-set variable in my xsl : The node-set variable looks like follow : <xsl:variable name="NodeSetXpathExpressions"> <xpath>/foo/bar[1]</xpath> <xpath>/foo/bar[2]</xpath> <xpath>/foo/bar[3]/baz[1]</xpath> </xsl:variable> each xapth expression is "abslolute" (starts with /root_element_name) (this variable is generated in the xsl from the string "/foo/bar[1], /foo/bar[2], /foo/bar[3]/baz[1]" passed as parameter to the xsl) And now I want to apply templates for each <xpath> of the $NodeSetXpathExpressions variable, I wrote : <xsl:for-each select="msxsl:node-set($NodeSetXpathNode)/xpath"> <xsl:variable name="xpathValue" select="."/> <xsl:apply-templates select="dyn:evaluate(.,$xpathValue)"/> </xsl:for-each> I get an error... I think it is because of the context node, which is the matched <xpath> node within the for-each element, so I wrote <xsl:apply-templates select="dyn:evaluate(/,$xpathValue)"/>, hopping the context node would be the root element of the xml from wich the apply-template make sens, but I also get the same error. I also tried : <xsl:apply-templates select="dyn:evaluate(/foo,$xpathValue)"/> <xsl:apply-templates select="dyn:evaluate(current(),$xpathValue)"/> with no success... Has someone any idea ? Thanks ! Matthieu.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Position() on template ma, Kevin L. Cobb | Thread | Re: [xsl] Dynamicaly applying templ, Ragulf Pickaxe |
Re: [xsl] XPath 2.0 / XSLT 2.0 stat, David Carlisle | Date | [xsl] xsl:sort not sorting (brain f, Brook Ellingwood |
Month |