[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: FW: How to store a node in a local variable using

Subject: RE: FW: How to store a node in a local variable using if or when
From: ohmson@xxxxxxxxxxxx (ohmson ampere)
Date: Fri, 01 Aug 2003 00:11:35 -0400
xsl variable node
I don't know...maybe this:

<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>

ohmson

Néstor Boscán <nestor.boscan@xxxxxxxxxx> wrote:

>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>
>
><xsl:for-each select="$node">
>    process
></xsl:for-each>
>
>Will not work because <xsl:value-of> only selects strings not nodes. So
><xsl:variable name="node" select="path"/> is not the same as
><xsl:variable name="node"><xsl:value-of select="path"/></xsl:variable>
>
>Second example use "select" attribute in variable:
>
><xsl:choose>
>    <xsl:when test="condition1">
>        <xsl:variable name="node"  select="/a/b/c"/>
>    </xsl:when>
>    <xsl:when test="condition2">
>        <xsl:variable name="node"  select="/c"/>
>    </xsl:when>
></xsl:choose>
></xsl:variable>
>
><xsl:for-each select="$node">
>    process
></xsl:for-each>
>
>Will not work because variable "node" is out of scope.
>
>Any ideas?
>
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>

__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.