You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/06/20 11:20:37 UTC
DO NOT REPLY [Bug 10050] New: -
org.apache.xml.serialize.XMLSerializer / super class BaseMarkupSerializer doesn't call the prepare-method, so the printer is null
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=10050>.
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=10050
org.apache.xml.serialize.XMLSerializer / super class BaseMarkupSerializer doesn't call the prepare-method, so the printer is null
Summary: org.apache.xml.serialize.XMLSerializer / super class
BaseMarkupSerializer doesn't call the prepare-method, so
the printer is null
Product: Xerces2-J
Version: 2.0.1
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Critical
Priority: Other
Component: Serialization
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: stefan.pottinger@web.de
CC: stefan.pottinger@web.de
I had to do some work during the parsing of a document and had to write some
parts of it to an output. So I used the XMLSerializer like this:
outputFormat = new OutputFormat("xml", "UTF-8", false);
outputFormat.setPreserveSpace(true);
outputFormat.setOmitXMLDeclaration(true);
recordWriter = new StringWriter();
recordSerializer = new XMLSerializer(recordWriter, outputFormat);
setContentHandler(recordSerializer);
Later I tried the following:
public void startElement(java.lang.String namespaceURI, java.lang.String
localName, java.lang.String qName, Attributes atts) throws SAXException {
....................
super.startElement(namespaceURI, localName, qName, atts);//to print sth to my
StringWriter
.....................
and I got:
java.lang.IllegalStateException: SER002 No writer supplied for serializer
org.apache.xml.serialize.XMLSerializer.startElement(XMLSerializer.java:258)
org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:575)
I looked in the source from the XMLSerializer and the BaseMarkupSerializer and
it seemed that the writer in the BaseMarkupSerializer wasn't mapped on the
_printer Variable. That should have been done in the
<BaseMarkupSerializer>.prepare() method. So I tried this after the
initialisation:
(look above)...
setContentHandler(recordSerializer);
try {recordSerializer.asContentHandler();}//!!!!!!!!!!!!!!!!!!!!!!!
catch (Exception e) {e.printStackTrace();}//!!!!!!!!!!!!!!!!!!!!!!!
With this workaround I could call the prepare()-method and it worked! It looks
like the serialize() of the BaseMarkupSerializer calls the prepare-method in
the beginning, but what if I don't use the serialize()? The writer is there but
where will the _printer be pointing to the _writer?
Hope you understand this.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org