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

Edelson, Justin Justin.Edelson at mtvn.com
Thu Oct 26 07:13:40 PDT 2006


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

If you see '?' when viewing the HTML source, you should check if you're using a text editor that understands UTF-8. If you see '?' in your browser, that could mean the character set used by the JSP page is not UTF-8. You can change this by using the page directive:
<%@ page contentType="text/html; charset=utf-8" %>

This would also obviate the need for the meta tag.

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

If you really want &###;, you should set the encoding in your stylehsheet to US-ASCII.

And be sure you're not setting disable-output-encoding to "yes". 

Justin



>-----Original Message-----
>From: jdom-interest-bounces at jdom.org 
>[mailto:jdom-interest-bounces at jdom.org] On Behalf Of John Monaco
>Sent: Thursday, October 26, 2006 7:25 AM
>To: jdom-interest at jdom.org
>Subject: [jdom-interest] Re: Why does setText(" ") not do what I want?
>
>
>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();
>doc.setRootElement(root);
>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;
>requ.setAttribute("Dokument",source);
>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">
><html>
><head>
><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
>_______________________________________________
>To control your jdom-interest membership:
>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>



More information about the jdom-interest mailing list