Subject: RE: [xsl] alternative to msxsl:node-set($variable) From: Andrew Kimball <akimball@xxxxxxxxxxxxx> Date: Wed, 10 Jan 2001 11:53:52 -0800 |
Paul, You wrote: > From what I've seen, it looks like using "msxsl:node-set($variable)" is what we need, but > our product is stuck with the May 2000 msxml parser, so we can't use it. > We'll upgrade the parser eventually, but we can't do it now... Actually what you need is some sort of xsl:evaluate function that compiles and executes XPath expressions at run-time. Although there is currently no extension function in MSXML that does what you need, you can easily write your own (that handles expressions returning node-sets), as follows: XSL === <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:some-prefix="some-uri" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <msxsl:script implements-prefix="some-prefix" language="jscript"> <![CDATA[ function selectNodes(nsetCtxt, strExpr) { // Evaluating strExpr must result in a node-set (unfortunately there is currently no evalExpr method on the MSDOM) return nsetCtxt.nextNode().selectNodes(strExpr); } ]]> </msxsl:script> <xsl:template match="Root"> <!-- May 2000 bits didn't fully support returning node-sets from functions. So the workaround is to bind the node-set to an xsl:param first and then use it. --> <xsl:param name="ActionPathVar" select="some-prefix:selectNodes(., string(ActionPath))"/> <xsl:for-each select="$ActionPathVar"> <xsl:value-of select="Text"/> </xsl:for-each> <!-- RTM bits would allow this instead (no need to use xsl:param or even xsl:variable unless you wanted to for some other reason): <xsl:for-each select="some-prefix:selectNodes(., string(ActionPath))"> --> </xsl:template> </xsl:stylesheet> XML === <Root> <ActionPath>Challenges/Incontrol/AspectNode/ActionNode[Action/@ID=21]</Actio nPath> <Challenges> <Incontrol> <AspectNode> <ActionNode> <Action ID='21'/> <Text>ActionNodeText</Text> </ActionNode> </AspectNode> </Incontrol> </Challenges> </Root> ~Andy Kimball MSXSL Dev -----Original Message----- From: Paul Thomas [mailto:pthomas@xxxxxxxxxxxxxxx] Sent: Wednesday, January 10, 2001 7:50 AM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Cc: Dayle Anderson; A. Sakthi Vel; Shyam Anand Subject: [xsl] alternative to msxsl:node-set($variable) Hi all, I've been searching all over the place for a way to handle our problem, and I can't find one. I hope someone on the list can help. From what I've seen, it looks like using "msxsl:node-set($variable)" is what we need, but our product is stuck with the May 2000 msxml parser, so we can't use it. We'll upgrade the parser eventually, but we can't do it now... What we want to do is this: 1. A user clicks on an html link to request something. Based on which link was clicked, we store an xpath expression in an xml element node, i.e. <ActionPath>Challenges/Incontrol/AspectNode/ActionNode[Action/@ID=21]</Actio nPath> 2. Later, we retrieve that path into a variable and use it in an xpath expression in order to show what the user wanted to see. e.g. <xsl:variable name="ActionPathVar" select="ActionPath"/> <xsl:for-each select="$ActionPathVar"> [show the stuff the user wanted...] </xsl:for-each> It seems like our problem is that we've got a result tree fragment in our ActionPathVar when what we need is a node-set. That much I think I've figured out from previous posts. But I haven't found a workaround to this that doesn't use a node-set() function. Any ideas would be much appreciated. Thanks a lot. Paul XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] alternative to msxsl:node, David Carlisle | Thread | [xsl] multiple documents, namespace, Dan Vint |
Re: [xsl] <xsl:copy-of>, David Carlisle | Date | Re: [xsl] Hyphenation in XSL FO, Sebastian Rahtz |
Month |