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 "Ruth, Brice" <br...@fiskars.com> on 2003/10/24 01:03:33 UTC
Using a variable XPath in JSTL xml statements
Good evening.
I'm using the JSTL xml statements and I find myself in a situation where
I want to dynamically determine if the "select" XPath used in an
<x:forEach> or <x:out> or whatever, is something like:
/country[@name=$country]/section[@name=$section]/category
- OR -
/country[@name=$country]/section
I've tried a great many things, using JSTL tags from the core library to
put one of those two strings in a page variable and then doing
<x:forEach select="$xml/$xpathPfx">
using scriptlets to assemble the xpath fragment and doing
<x:forEach select="$xml/<%=xpathPfx%>
to practically any number of other things and I always get a
ServletException stating that the XPath processor expected one of
'.','..','@', etc.
Is there any way for me to do this?
Thanks!
--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: Using a variable XPath in JSTL xml statements
Posted by "Ruth, Brice" <br...@fiskars.com>.
OK, thanks. That's too bad.
Marius Scurtescu wrote:
> The spec says that the 'select' attribute is not dynamic,
> accepts only a string. It probably does not interpret
> the expressions you put there.
>
> You may have to use some if tags (c:if or x:if) and write
> two versions of your x:forEach.
>
> Marius
>
> Ruth, Brice wrote:
>
>> Good evening.
>>
>> I'm using the JSTL xml statements and I find myself in a situation
>> where I want to dynamically determine if the "select" XPath used in
>> an <x:forEach> or <x:out> or whatever, is something like:
>>
>> /country[@name=$country]/section[@name=$section]/category
>>
>> - OR -
>>
>> /country[@name=$country]/section
>>
>> I've tried a great many things, using JSTL tags from the core library
>> to put one of those two strings in a page variable and then doing
>>
>> <x:forEach select="$xml/$xpathPfx">
>>
>> using scriptlets to assemble the xpath fragment and doing
>>
>> <x:forEach select="$xml/<%=xpathPfx%>
>>
>> to practically any number of other things and I always get a
>> ServletException stating that the XPath processor expected one of
>> '.','..','@', etc.
>>
>> Is there any way for me to do this?
>>
>> Thanks!
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
--
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: Using a variable XPath in JSTL xml statements
Posted by Marius Scurtescu <ma...@lightspeed.ca>.
The spec says that the 'select' attribute is not dynamic,
accepts only a string. It probably does not interpret
the expressions you put there.
You may have to use some if tags (c:if or x:if) and write
two versions of your x:forEach.
Marius
Ruth, Brice wrote:
> Good evening.
>
> I'm using the JSTL xml statements and I find myself in a situation where
> I want to dynamically determine if the "select" XPath used in an
> <x:forEach> or <x:out> or whatever, is something like:
>
> /country[@name=$country]/section[@name=$section]/category
>
> - OR -
>
> /country[@name=$country]/section
>
> I've tried a great many things, using JSTL tags from the core library to
> put one of those two strings in a page variable and then doing
>
> <x:forEach select="$xml/$xpathPfx">
>
> using scriptlets to assemble the xpath fragment and doing
>
> <x:forEach select="$xml/<%=xpathPfx%>
>
> to practically any number of other things and I always get a
> ServletException stating that the XPath processor expected one of
> '.','..','@', etc.
>
> Is there any way for me to do this?
>
> Thanks!
>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org