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 Wong Kok Wai <wo...@pacific.net.sg> on 2000/05/26 16:43:26 UTC
Problem with XML serialiser
The following code works in Xerces-J 1.0.4 but throws the following
exception in 1.1.0:
java.lang.IllegalStateException: SER002 No writer supplied for
serializer
at
org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:437)
private boolean write(File file, Document doc, OutputFormat of) {
boolean result = true;
PrintWriter pw = null;
try {
pw = new PrintWriter(new BufferedOutputStream(new
FileOutputStream(file)));
XMLSerializer xser = new XMLSerializer(pw, of);
xser.serialize(doc);
} catch (Exception e) {
System.out.println("SaveManager.write: " + e);
e.printStackTrace(System.err);
result = false;
} finally {
if (pw != null) {
pw.close();
}
}
return result;
}
Re: Problem with XML serialiser
Posted by Theofanis Vassiliou-Gioles <va...@fokus.gmd.de>.
Hi,
it looks like this question will occur more often. (Actually, I ran
into the same problem. The code worked with the old version but not with
the new one.)
However here again the solution:
The main point is that you need a DOMSerializer, i.e. the XMLSerializer
should behave like DOMSerializer. Therefore you have to call the
asDOMSerializer-method of the XMLSerializer.
So change your code in the following way:
XMLSerializer xser = new XMLSerializer(pw, of);
DOMSerializer dser = xser.asDOMSerializer();
dser.serialize(doc);
Best regards,
Theo
__________________________
Theofanis Vassiliou-Gioles email: vassiliou@fokus.gmd.de
GMD FOKUS phone: +49 (30) 3463 - 7346
Kaiserin-Augusta-Allee 31 room : 3008
D-10589 Berlin http://www.fokus.gmd.de/usr/vassiliou/
On Fri, 26 May 2000, Wong Kok Wai wrote:
> The following code works in Xerces-J 1.0.4 but throws the following
> exception in 1.1.0:
>
> java.lang.IllegalStateException: SER002 No writer supplied for
> serializer
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:437)
>
> private boolean write(File file, Document doc, OutputFormat of) {
> boolean result = true;
> PrintWriter pw = null;
> try {
> pw = new PrintWriter(new BufferedOutputStream(new
> FileOutputStream(file)));
> XMLSerializer xser = new XMLSerializer(pw, of);
> xser.serialize(doc);
> } catch (Exception e) {
> System.out.println("SaveManager.write: " + e);
> e.printStackTrace(System.err);
> result = false;
> } finally {
> if (pw != null) {
> pw.close();
> }
> }
> return result;
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>