You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Digby <li...@digby.net> on 2004/09/04 19:47:58 UTC

How do I pass a variable into an x select?

I've just noticed that the select attribute of all the x tags isn't 
ynamic, so I can't pass in a variable - which is kind of exactly what I 
need to do. Is there a workaround, or am I going to have to abandon jstl 
xml for xsl or something?

What I'm trying to do is below (v variable fails, but I can't hardcode 
the "two" for obvious reasons.

TIA

Digby

<x:parse var="xml">
     <channels id="channels">
         <channel id="tv">
             <channel id="one"/>
             <channel id="two"/>
             <channel id="three"/>
             <channel id="four"/>
         </channel>
         <channel id="sky">
             <channel id="movies"/>
             <channel id="sports"/>
         </channel>
     </channels>
</x:parse>
<c:set var="v" value="three"/>
Self: <x:out select="$xml//channel[@id='two']/@id"/>
Index: <x:out select="$xml/channels/@id"/>
Parent: <x:out select="$xml//channel[@id='${v}']/../@id"/> <!--FAILS!-->
First: <x:out 
select="$xml//channel[@id='two']/../channel[position()=1]/@id"/>
Last: <x:out 
select="$xml//channel[@id='two']/../channel[position()=last()]/@id"/>
Next: <x:out 
select="$xml//channel[@id='two']/following-sibling::channel/@id"/>
Prev: <x:out 
select="$xml//channel[@id='two']/preceding-sibling::channel/@id"/>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org