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 Lisa Retief <li...@exinet.co.za> on 2000/05/11 10:44:08 UTC
Serialization breaks in Xerces 1.0.4
The following code to serialize an XML document worked great with Xerces
1.0.3. Once I have upgraded to 1.0.4 it breaks.
ByteArrayOutputStream b = new ByteArrayOutputStream();
SerializerFactory factory = SerializerFactory.getSerializerFactory("xml");
XMLSerializer serializer = (XMLSerializer) factory.makeSerializer(b, new
OutputFormat());
serializer.serialize(document);
The exception I get is:
java.lang.IllegalStateException: SER002 No writer supplied for serializer
at
org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer
.java:437)
I have also tried to explicitly set a Writer or OutputStream for the
Serializer, but the same exception gets thrown.
Any feedback would be appreciated.
Lisa
Re: Serialization breaks in Xerces 1.0.4
Posted by Arkin <ar...@exoffice.com>.
Although you can call serializer.serialize( document ) this is not part
of the API. You need to call asDOMSerializer() first to get a serializer
on which you can call serialize( document ).
(This separation will be reflected in a future version of the API)
arkin
David Blondeau wrote:
>
> > The following code to serialize an XML document worked great with Xerces
> > 1.0.3. Once I have upgraded to 1.0.4 it breaks.
> >
> > ByteArrayOutputStream b = new ByteArrayOutputStream();
> > SerializerFactory factory = SerializerFactory.getSerializerFactory("xml");
> > XMLSerializer serializer = (XMLSerializer) factory.makeSerializer(b, new
> > OutputFormat());
> > serializer.serialize(document);
> >
> > The exception I get is:
> > java.lang.IllegalStateException: SER002 No writer supplied for serializer
> > at
> >
> org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer
> > .java:437)
> >
> > I have also tried to explicitly set a Writer or OutputStream for the
> > Serializer, but the same exception gets thrown.
> >
> > Any feedback would be appreciated.
>
> I Lisa,
>
> I got the same problem. You just need to call one of the method
> asContentHandler(), asDocumentHandler() or asDOMSerializer() before the
> call to serialize() in order to prepare the serializer. For your example,
> you should do
> serializer.asDOMSerializer().serialize(document);
>
> David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
--
----------------------------------------------------------------------
Assaf Arkin www.exoffice.com
CTO, Exoffice Technologies, Inc. www.exolab.org
Re: Serialization breaks in Xerces 1.0.4
Posted by David Blondeau <bl...@exoffice.com>.
> The following code to serialize an XML document worked great with Xerces
> 1.0.3. Once I have upgraded to 1.0.4 it breaks.
>
> ByteArrayOutputStream b = new ByteArrayOutputStream();
> SerializerFactory factory = SerializerFactory.getSerializerFactory("xml");
> XMLSerializer serializer = (XMLSerializer) factory.makeSerializer(b, new
> OutputFormat());
> serializer.serialize(document);
>
> The exception I get is:
> java.lang.IllegalStateException: SER002 No writer supplied for serializer
> at
>
org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer
> .java:437)
>
> I have also tried to explicitly set a Writer or OutputStream for the
> Serializer, but the same exception gets thrown.
>
> Any feedback would be appreciated.
I Lisa,
I got the same problem. You just need to call one of the method
asContentHandler(), asDocumentHandler() or asDOMSerializer() before the
call to serialize() in order to prepare the serializer. For your example,
you should do
serializer.asDOMSerializer().serialize(document);
David