[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] FW: How to store a node in a local variable using if or when
Subject: Re: [xsl] FW: How to store a node in a local variable using if or when From: Américo Albuquerque <melinor@xxxxxxx> Date: Fri, 01 Aug 2003 14:32:15 +0100 (WEST) |
Hi Citando Néstor Boscán <nestor.boscan@xxxxxxxxxx>: } Hi } } I would like to process information from a node that can come from two } different places in the XML tree. Because the processing is the same I } create a variable and with a choice element I will set the variable to } one of the two nodes. So I can figure out only two ways of doing it that } doesn't work. Here are the two examples: } } First example use <xsl:value-of>: } } <xsl:variable name="node"/> } <xsl:choose> } <xsl:when test="condition1"> } <xsl:value-of select="/a/b/c"/> } </xsl:when> } <xsl:when test="condition2"> } <xsl:value-of select="/c"/> } </xsl:when> } </xsl:choose> } </xsl:variable> } Try this instead: <xsl:variable name="node" select="/a/b/c[condition1] | /c[condition2]"/> you could also use: <xsl:variable name="node"> <xsl:choose> <xsl:when test="condition1"> <xsl:copy-of select="/a/b/c"/> </xsl:when> <xsl:when test="condition2"> <xsl:copy-of select="/c"/> </xsl:when> </xsl:choose> </xsl:variable but then you'll have to use a node-set() function to use it: <xsl:for-each select="fn:node-set($node)"> ... </xsl:for-each> Hope this helps you. (...) Regards, Americo Albuquerque ___________________________________________________________________ O SAPO já está livre de vírus com a Panda Software, fique você também! Clique em: http://antivirus.sapo.pt XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] FW: How to store a node i, Néstor Boscán | Thread | [xsl] Re: How to store a node in a , Dimitre Novatchev |
[xsl] creating an rtf/node-set from, Gary Tyree | Date | RE: [xsl] creating an rtf/node-set , Jeff Beadle |
Month |
Keywords