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

'xsl:variable' as dynamic select for 'xsl:for-each'...

Subject: 'xsl:variable' as dynamic select for 'xsl:for-each'...
From: Ollie Lord <ol@xxxxxxx>
Date: Mon, 17 Nov 2003 12:15:58 +0000
xsl variable for each
Hi all,

I'm having problems creating an xsl:variable that I can use as the node set for an 'xsl:for-each' tag.

Basiacally...
    <xsl:variable name="selectclause" select=" some nodes "/>
    <xsl:for-each select="$selectclause">
       ... my code...
    </xsl:for-each>


My problem is that the select statement of the variable needs to be dynamic. Such as... (and I know this doesn't work.. )


  <xsl:choose>
    <xsl:when test="$clientid = ''">
       <xsl:variable name="selectclause" select = "//client"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="selectclause" select = "//client[$clientid]"/>
    </xsl:otherwise>
  </xsl:choose>

  <xsl:for-each select="$selectclause">
	my code
  </xsl:for-each>

It doesn't work because the contents of the variable 'selectclause' cannot be changed.


Of course, this doesn't work either...


    <xsl:variable name="selectclause">
      <xsl:choose>
        <xsl:when test="$clientid = ''">"//client"</xsl:when>
        <xsl:otherwise>"//client[$clientid]"</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

  <xsl:for-each select="$selectclause">
	my code
  </xsl:for-each>


... because the content of $selectclause isn't a node set.


Does anyone have any advice for me?? Any help would be very much appreciated.

Thanks,
Ollie Lord.



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.