[SoapRMI] XPP3Reader and ampersand escape sequences
Aleksander Slominski
aslom_at_cs.indiana.edu
Thu, 15 Feb 2007 08:47:35 -0500
Brian Lewis wrote:
> 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 -> Q </p>". It produces
> "<p>P -> Q</p>".
>
> But when I switch to XPP3Reader, the ">" 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 -> 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?
>
hi,
what verison of dom4j and xpp3 did you use?
best,
alek