[jdom-interest] Re: Why does setText(" ") not do what I want?

John Monaco john.monaco at gmx.de
Thu Oct 26 04:24:49 PDT 2006

Many thanks for your replies, especially thanks to Justin Edelson. I made some success but the output via xsl is not working yet.

Input is working:
I use the Windows tool charmap.exe to insert a special character (the alpha) in the input control of my html form. So I get the correct unicode term, in case of Alpha it is similar to type "& # 945 ;" (the extra spaces are for clarity).

The data of the html form comes as strings to a java servlet. Here I use StringEscapeUtils.unescapeXml(String), as Justin recommended. Then I build the tree with the strings using JDOM methods and give the document to the database.

I use the XML database tamino and there I really see an Alpha and not "& amp ; # 945 ;"
Furthermore I can query the database with "& # 945 ;" instead of "& amp ; # 945 ;" like before and find the document.

Output process via xsl 
In this process is no step where I have strings to use escapeXml. Instead of Alpha a '?' is shown in the html output.

What I'm doing:
I get the document as root from the database and put it in source:

org.jdom.Document doc = new Document();
JDOMSource  source = new JDOMSource(doc);

With a dispatcher that contains HttpServletRequest requ and HttpServletResponse resp I give the source to a JSP file:

RequestDispatcher dispatcher;
dispatcher = getServletContext().getRequestDispatcher(myJspFile.jsp);
dispatcher.forward(requ, resp);

In the JSP file I use the Jakarta XTags library to transform XML to html.

<% org.jdom.transform.JDOMSource doc = (org.jdom.transform.JDOMSource)request.getAttribute("Dokument");%>
<xtags:style xmlSource="<%= doc%>" xsl="myStylesheet.xsl"/>

By the way, the head of myStylesheet.xsl looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>

and the head of myJspFile.jsp like that:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

I think somewhere in this process I have to change the unicode character to &#xxx; that the browser shows the character instead of '?'.

Does any one know how I can do this?

GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl

More information about the jdom-interest mailing list