Altova Mailing List Archives


Re: [xsl] 'xsl:variable' as dynamic select for 'xsl:for-each'...

From: "john prieur" <john2000@------------>
To:
Date: 11/17/2003 4:11:00 AM
you must be thinking in Perl.  find an algorithm that does what you need
without having to generate the variable names during execution. there might
be a way to do what you asked, but I'm not an expert and don't think there
is a way.

----- Original Message -----
From: "Ollie Lord" <ol@xxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, November 17, 2003 7:15 AM
Subject: [xsl] 'xsl:variable' as dynamic select for 'xsl: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
>


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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.