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: Problem when a use a x:forEach into another x:forEach
Date Sat, 27 Jan 2007 04:06:27 GMT
Are you getting any errors in the log? 

When you upgrade from JSTL1.0 to JSTL1.1 you need to make some changes or verify these changes:

1) Use Servlet 2.4 jar

2) Change web.xml to servlet 2.4 version:

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

3) Change tag library declarations to:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
Similarly upgrade other JSTL namespace URIs

-Rashmi

----- Original Message ----
From: S├ębastien Brodeur <brodseba@gmail.com>
To: taglibs-user@jakarta.apache.org
Sent: Friday, January 26, 2007 2:03:02 PM
Subject: Problem when a use a x:forEach into another x:forEach


I'm currently migrating my application from WebSphere 5 (JSTL 1.0) to
WebSphere 6 (JSTL 1.1), and so far, the XML taglibs give us a lot of
trouble.

For example :

------------------------------------------------------------------------------------------------------
collections.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<collections>
  <collection>
    <id>horror</id>
    <name>Horror novel</name>
  </collection>
  <collection>
    <id>scifi</id>
    <name>Sci-Fi novel</name>
  </collection>
</collections>

------------------------------------------------------------------------------------------------------
books.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<books>
  <book>
    <collection_id>scifi</collection_id>
    <title>Robots</title>
  </book>
  <book>
    <collection_id>scifi</collection_id>
    <title>The Moon is a Hashes Mistress</title>
  </book>
  <book>
    <collection_id>scifi</collection_id>
    <title>Spaceship Tropper</title>
  </book>
  <book>
    <collection_id>horror</collection_id>
    <title>This</title>
  </book>
</books>

------------------------------------------------------------------------------------------------------
books.jsp

<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
<%@ taglib prefix="x" uri="/WEB-INF/x.tld" %>

<c:import var="xml_collections" url="http://localhost/collections.xml"; />
<x:parse xml="${xml_collections}" var="collections" scope="request"/>

<c:import var="xml_books" url="http://www.localhost/books.xml"; />
<x:parse xml="${xml_books}" var="books" scope="request"/>

<x:forEach select="$collections/collections/collection" var="collection">
  <x:out select="$collection/name" />
  <ul>
    <x:forEach select="$books/books/book[collection_id=$collection/id]"
var="book">
      <li><x:out select="$book/title" /></li>
    </x:forEach>
  </ul>
</x:forEach>

------------------------------------------------------------------------------------------------------
Output (WebSphere 5 using JSTL 1.0)

  Horror novel
  <ul>
      <li>This</li>
  </ul>

  Sci-Fi novel
  <ul>
      <li>Robots</li>
      <li>The Moon is a Hashes Mistress</li>
      <li>Spaceship Tropper</li>
  </ul>

------------------------------------------------------------------------------------------------------

Output (WebSphere 6 using JSTL 1.1)

  Horror novel
  <ul>
  </ul>
  Sci-Fi novel
  <ul>
  </ul>


Any idea how to do that without changing the structure of the two XML files?

Thank!

-- 
S├ębastien Brodeur
brodseba@iname.com
Site Web : http://www.un-programmeur-php.ca/


 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.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