aspose file tools*
The moose likes JSP and the fly likes JSTL unicode xml does not display after x:parse call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL unicode xml does not display after x:parse call" Watch "JSTL unicode xml does not display after x:parse call" New topic
Author

JSTL unicode xml does not display after x:parse call

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
Hi all, thanks in advance for this one.

I am trying to display an xml file on the web using JSTL xml tags. The file is encoded in utf-8 containing ancient Greek characters (x1f92, etc.). The file displays properly from a servlet + xslt (http://163.1.169.41/testapp), but I want to use JSTL.

The JSTL produces intricate spaghetti on the screen (e.g. �†������������� ). I have seen this before --it would seem that unicode is indeed being directed at the screen but is not being interpreted properly. (Not strings of question marks mind you; the unicode seems to be there in this case).

The code producing the spaghetti is below. I am just dumping in on the screen for now and will use xpath calls later for more precise extraction.

Does the JSTL want character entities for the x arse call? I would not think so: parsing a utf-8 file would be a very common operation. How can I get the xml unicode file to display properly using the JSTL below?


[headers]
<%@ page contentType="text/html; charset=utf-8"pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

...


<c:import var="papyrus" url="blabula.xml" />
<x arse var="doc" xml="${papyrus}" />
<x ut select="$doc" />

....
Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
Oops, didn't see the directions. Platform is Tomcat 5.28 and JSTL 1.1.
Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
Hi all,

Figured it out. Simply add a charEncoding="UTF-8" to the import tag does the trick:

<c:import var="papyrus"
charEncoding="UTF-8" url="blabula.xml" />
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL unicode xml does not display after x:parse call