Java Mailing List Archive

http://www.junlu.com/

Home » JDOM Projects »

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

SoTaNeZ

2013-01-09

Replies: Find Java Web Hosting

Author LoginPost Reply
Hello.

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;
default:
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.setTextMode(TextMode.PRESERVE);
formato.setEscapeStrategy(new EscapeSimbolos());
formato.setIgnoreTrAXEscapingPIs(true);
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:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.