You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/09/11 19:12:07 UTC
DO NOT REPLY [Bug 23113] New: -
org.apache.xml.serializer.Serializer.reset() resets ampersand entity handling
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23113>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23113
org.apache.xml.serializer.Serializer.reset() resets ampersand entity handling
Summary: org.apache.xml.serializer.Serializer.reset() resets
ampersand entity handling
Product: XalanJ2
Version: 2.5Dx
Platform: Other
OS/Version: Linux
Status: NEW
Severity: Major
Priority: Other
Component: org.apache.xml.utils
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: nsushkin@sushkins.net
With xalan 2.5.1, I parse the following xml: <Bug>" & '</Bug> and serialize
via org.apache.xml.serializer.Serializer. I get the correct result. After I do
serializer.reset() and serialize again, I do get broken (not well-formed) XML
<Bug>" & '</Bug>.
Here's the test case:
import java.io.StringReader;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import org.apache.xml.serializer.OutputPropertiesFactory;
import org.apache.xml.serializer.Serializer;
import org.apache.xml.serializer.SerializerFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
public class SerializerBug
{
public static void main(String[] args) throws Exception
{
String xml = "<Bug>\" & '</Bug>";
Document doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
InputSource(new StringReader(xml)));
Properties op =
OutputPropertiesFactory.getDefaultMethodProperties("xml");
op.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
Serializer s = SerializerFactory.getSerializer(op);
s.setOutputStream(System.out);
System.out.print("Initial serialize: ");
s.asDOMSerializer().serialize(doc);
System.out.println();
System.out.print("reset and do not set output format: ");
s.reset();
s.asDOMSerializer().serialize(doc);
System.out.println();
System.out.print("reset and set output format: ");
s.reset();
s.setOutputFormat(op);
s.asDOMSerializer().serialize(doc);
System.out.println();
}
}