[SoapRMI] XPP3Reader and ampersand escape sequences

Brian Lewis bsl04_at_uark.edu
Thu, 15 Feb 2007 02:57:35 -0600


The pretty printing example found at
http://www.dom4j.org/apidocs/org/dom4j/io/HTMLWriter.html works as
expected with the XHTML input "<p>   P -&gt; Q   </p>". It produces
"<p>P -&gt; Q</p>".

But when I switch to XPP3Reader, the "&gt;" vanishes from the output and
I'm left with "<p>P - Q</p>".

Here is the code:

import java.io.ByteArrayInputStream;
import java.io.StringWriter;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.HTMLWriter;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XPP3Reader;

public class Test
{
	public static void main(String arguments[])
		throws java.io.IOException,
org.dom4j.DocumentException, org.xmlpull.v1.XmlPullParserException {
		String html = "<p>   P -&gt; Q   </p>";
		StringWriter sw = new StringWriter();
		OutputFormat format = OutputFormat.createPrettyPrint();
		format.setExpandEmptyElements(true);
		format.setNewlines(true);
		format.setIndentSize(1);
		format.setIndent("\t");
		format.setTrimText(true);
		format.setPadText(true);
		format.setXHTML(true);
		format.setExpandEmptyElements(true);

		HTMLWriter writer = new HTMLWriter(sw, format);
		XPP3Reader reader = new XPP3Reader();
		Document document = reader.read(new
ByteArrayInputStream(html.getBytes())); writer.write(document);
		writer.flush();
		System.out.println(sw.toString());
	}
}

I use XPP3Reader as part of a pretty-printing servlet filter. I need to
put a right-facing ASCII arrow in my XHTML, but the greater-than escape
sequence is being done away with.

Is this a problem with XPP3Reader?

Thank you.