By definition a serializer is good for printing just one document, and
it prints just one document.

Although it's possible to print two documents with domSerializer, I'm
not sure if it makes sense with a DocumentHandler/ContentHandler, so I
would advise against it.

arkin


Arnaud Le Hors wrote:
> 
> The documentation is really sparse on this so maybe I'm just using it in
> a way which is not intended but it appears to me that using the same
> serializer for more than one document fails.
> 
>      XMLSerializer serializer = new XMLSerializer(System.out, null);
>      System.out.println("Doc1:");
>      serializer.serialize(doc1);
>      System.out.println("Doc2:");
>      serializer.serialize(doc2);
> 
> gives:
> 
> Doc1:
> <?xml version="1.0"?>
> <el1><el1.2/></el1>
> Doc2:
> <el2><el1.1 a1="v1" a2="v2"><el1.1.1/></el1.1></el2>
> 
> The XML declaration is missing in the second output.
> To make this work I have to patch BaseMarkupSerializer.java like this:
> 
> diff -c -r1.11 BaseMarkupSerializer.java
> *** BaseMarkupSerializer.java   2000/02/23 21:41:18     1.11
> --- BaseMarkupSerializer.java   2000/03/06 23:46:49
> ***************
> *** 416,421 ****
> --- 416,422 ----
>           if ( _writer == null )
>               throw new IllegalStateException( "SER002 No writer
> supplied for serializer" );
>           try {
> +           reset();
>               startDocument();
>           } catch ( SAXException except ) { }
>           serializeNode( doc );
> 
> Again, I'm not sure this is a valid use of it though, so I'm not sure
> it's ok to commit my changes.
> --
> Arnaud  Le Hors - IBM Cupertino, XML Technology Group

-- 
----------------------------------------------------------------------
Assaf Arkin                                           www.exoffice.com
CTO, Exoffice Technologies, Inc.                        www.exolab.org

Reply via email to