tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bb...@brakus.com
Subject Re: x:set var
Date Mon, 13 Jan 2003 18:32:50 GMT
Shawn,

Thanks for both the explanation and the "fix."  This is definitely one of
those "duhhhh" moments, after reading your explanation.  Works perfectly
now.

Best regards,
Buck Bell


>-- Original Message --
>Reply-To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
>Date: Mon, 13 Jan 2003 13:19:57 -0500 (EST)
>From: Shawn Bayern <bayern@essentially.net>
>To: Tag Libraries Users List <taglibs-user@jakarta.apache.org>
>Subject: Re: x:set var
>
>
>On Mon, 13 Jan 2003 bbell@brakus.com wrote:
>
>> All,
>> 
>> For the life of me, I cannot figure out why the following examples produce
>> different results.  Many thanks in advance if anyone can help.
>> 
>> I'm importing an XML doc with the following:
>> 
>> <x:parse var="reports">
>> 	<c:import url="reports.xml"/>
>> </x:parse>
>> 
>> If I use
>> 
>> <x:out select="$reports//report[@shortname='biweekly']/id" />
>> 
>> I get the expected result, "157."
>> 
>> However, if I use
>> 
>> <x:set var="reportID" select="$reports//report[@shortname='biweekly']/id"
>> />
>> 
>> <c:out value="${reportID}" />
>> 
>> I get, "[[id: null]]".
>> 
>> The xPath syntax is obviously correct, as I'm getting the expected
>> result with the x:out tag.  So, any idea what I'm doing wrong when I
>> try to expose the same result in the variable reportID?
>
>The <x:out> tag uses the string-value of the element you have selected.

>
><x:set> stores the object representing that node itself, and then <c:out>
>prints the toString() value of that node -- which, per the DOM API, isn't
>the same thing as what XPath means by "string-value."
>
>To store the value you expect instead of outputting it immediately, you
>should use a pattern like
>
> <c:set>
>  <x:out>
> </c:set>
>
>instead of <x:set>.  Alternatively, you can wrap the XPath expression in
>the string() function and continue to use <x:set>.
>
>Hope that helps,
>
>-- 
>Shawn Bayern
>"JSTL in Action"   http://www.manning.com/bayern
>
>
>--
>To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>
>



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


Mime
View raw message