Outputting Entity References for special Characters.

[email protected] Mon, 21 Apr 2003 14:56:23 -0400
Newsgroups gmane.comp.jakarta.ecs.user
Message-ID <[email protected]>



Is there anyway to have special characters embedded in an XML element be
outputted using the character's entity reference when either using the
XML.toString() method or the XMLDocument.output(OutputStream) method? For
example:

XMLDocument doc = new XMLDocument();
XML element = new XML("test");
element.setTagText("lets see how the less than sign is outputted: <");
doc.addElement(element);

OutputStream os = new ByteArrayOutputStream();
doc.output(os);

System.out.println(element);
System.out.println(os);

Output produced by the above:
<test>lets see how the less than sign is outputted: <</test>
<?xml version="1.0" standalone="yes"?><test>lets see how the less than sign
is outputted: <</test>

Whereas I would really like the output to look like this:
<test>lets see how the less than sign is outputted: &lt;</test>
<?xml version="1.0" standalone="yes"?><test>lets see how the less than sign
is outputted: &lt;</test>

Thanks.
_______________________
David Howie
Customer Service Systems
(717) 731-2513
[email protected]