tags:

views:

114

answers:

3

I would like to do something like this:

<x:out select="$productXML/product/sizes/size[<c:out value='${param.sizeIndex}'/>]" escapeXml="false"/>

but I think the only way to do it is like this:

<x:forEach var="size" begin="${param.sizeIndex}" end="${param.sizeIndex+1}" select="$productXML/product/sizes/*">  
    <x:out select="$size" escapeXml="false"/>
</x:forEach>

Is there a way to do it more like the way I want to?

A: 

Not sure what are you trying to solve, but are you sure you need the <c:out value='${param.sizeIndex}'/> inside the '[]' ? JSTL should be processed all at the same time, and you should be able to write something like:

<x:out select="$productXML/product/sizes/size[param.sizeIndex]" escapeXml="false"/>

Or maybe using <c:set var="sIdx" value="${param.sizeIndex}" />

But I'm not totally familiar with JSTL XML tags to be 100% sure...

GClaramunt
Makes sense. I tried it though, and it doesn't work. At least it doesn't produce a compiler error though, it just silently fails.
Dennis
A: 

I think I found what are you looking for here:

<x:set var="abook"
select="$applicationScope.booklist/
        books/book[@id=$param:bookId]" />
  <h2><x:out select="$abook/title"/></h2>
GClaramunt
Thank you very much for your help. I would give you 75% credit for this answer. It put me on the right track, but it is not exactly the correct answer because my question had nothing to do with books, or variables such as 'abook', and I am not using 'id' attributes.
Dennis
+1  A: 

Thanks to GClaramunt [user 98867] putting me on the right tack, I discovered the correct answer:

<x:out select="$productXML/product/sizes/size[$param:sizeIndex]" escapeXml="false"/>
Dennis