[jdom-interest] How to not expand entities?

David Kavanagh dak at dotech.com
Tue Sep 10 18:00:21 PDT 2002

I think you need to extend XMLOutputter. You can override 
escapeElementEntities() to escape the character ranges you are 
interested in (perhaps those with values over 127?).


Indrayan, Rahul wrote:

>Again, a question related to the same code: -
>import java.io.*;
>import org.jdom.*;
>import org.jdom.input.*;
>import org.jdom.output.*;
>public class Spike {
>	public static void main(String args[]) {
>		try {
>			SAXBuilder builder = new SAXBuilder(false);
>			builder.setExpandEntities(false);
>			String xml = "<?xml version=\"1.0\"
>encoding=\"UTF-8\"?><!DOCTYPE root SYSTEM \"foo.dtd\"><root><proof>This is
>&#xe1; foofoo &#xf3; stuff!</proof></root>";
>			new XMLOutputter().output(
>				builder.build(new StringReader(xml)),
>					new PrintWriter(new
>		}
>		catch (Exception e) { e.printStackTrace(); }
>	}
>How do I output the XML to a string so that unicode such as &#xe1; does not
>get expanded and the file represent the special characters with their
>unexpanded equivalents (i.e., &#xe1;)?
>This e-mail and any files transmitted with it may contain privileged or 
>confidential information. It is solely for use by the individual for whom 
>it is intended, even if addressed incorrectly. If you received this e-mail 
>in error, please notify the sender; do not disclose, copy, distribute, or 
>take any action in reliance on the contents of this information; and delete 
>it from your system. Any other use of this e-mail is prohibited. Thank you 
>for your compliance.
>To control your jdom-interest membership:

More information about the jdom-interest mailing list