Java Mailing List Archive

Home » JDOM Projects »

[jdom-interest] EscapeStrategy for in-text html tags not working



Replies: Find Java Web Hosting

Author LoginPost Reply

I have some XML elements which text is not plain, but contains some HTML tags.
The thing is that when outputting these to an XML file the characters "<" and ">" are changed into "&lt;" and "&gt;" preventing its correct posterior HTML processing.
I tried using this EscapeStrategy:

class EscapeSimbolos implements EscapeStrategy {

public boolean shouldEscape(char car) {
switch (car) {
case '<':
return false;
case '>':
return false;
return false;

but with no effect. The code within the two case statements is never reached, but the method is executed, so it seems that these characters are converted before the EscapeStrategy gets into action, or maybe I am doing something wrong.

This is the code to set the format:

Format formato = Format.getPrettyFormat();
formato.setEscapeStrategy(new EscapeSimbolos());
XMLOutputter outputter = new XMLOutputter(formato);

I tried setting setIgnoreTrAXEscapingPIs to false, because I am not sure what this does exactly, but nothing seems to change.

Any ideas?
To control your jdom-interest membership:
©2008 - Jax Systems, LLC, U.S.A.