tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rashmi Rubdi <dev_subscripti...@yahoo.com>
Subject Re: XPath Not() function always returning false AND <x:forEach> context question.
Date Fri, 06 Oct 2006 23:47:36 GMT
My environment is JSTL1.1 Tomcat5.5

To simplify things, I tried this:

<x:out select="not($xml/books/book[@id='1'])"/>
The above statement returned *true*, I believe it
should have returned *false* because the book node has
an attribute id with value 1, which evaluates to true,
and not(true)is false. But, it's returning true
instead.

The same statement in XSLT 1.0 returned false - which
is how it should work.
<xsl:template match="/">
  <xsl:value-of select="not(books/book[@id='1'])"/>
</xsl:template>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Regarding the forEach, I tested this:

<x:forEach select="$xml/books/book">
   <x:out select="$xml/books/collection/name"/>
</x:forEach>

It didn't give any output, but since the collection
node is not a child of the book node but of it's
parent you may want to do this:

<x:out select="$xml/books/collection/name"/>
<x:forEach select="$xml/books/book">
</x:forEach>

When tested the for each equivalant of the JSTL
statement you have mentioned in XSLT1.0 this worked:
<xsl:template match="/">
  <xsl:for-each select="books/book">
     <xsl:value-of select="/books/collection/name"/>
  </xsl:for-each>
</xsl:template>

-Rashmi


--- Sébastien Brodeur <brodseba@gmail.com> wrote:

> We are migrating from WebSphere 5 (and JSTL 1.0) to
> WebSphere 6 (JSTL 1.1).
> 
> We have some incompatibility issues.
> 
> When I try to use the XPath not() function to
> evaluate if a select statement
> will return something, I always get false.
> 
> Example:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <books>
> 
>   <collection>
>     <name>My collection</name>
>   </collection>
> 
>   <book id="1">
>     <author>Isaac Asimov</author>
>     <title><![CDATA[La cité des robots]]></title>
>     <year>1980</year>
>   </book>
> </books>
> 
> ...
> <x:when select="not($xml/books/book[id=1]">
> ...
> 
> Will return false EVEN if the id exist.
> 
> 
> Also, when I uses <x:forEach>, I can't no longer
> access XML node outside the
> scope of the select.  I have to use a 'weird' syntax
> to access those nodes.
> 
> Work in JSTL 1.0 and don't in JSTL 1.1
> 
> <x:forEach select="$xml//books/book"
> var="current_book">
>   <x:out select="$xml//books/collection/name" />
> </x:forEach>
> 
> I must uses instead
> 
> <x:forEach select="$xml//books/book"
> var="current_book">
>   <x:out select="current_book/../collection/name" />
> </x:forEach>
> 
> -- 
> Sébastien Brodeur
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message