When I try to use the XML serializer in Xerces 1.1.2, I get the
following exception:

java.lang.IllegalStateException: SER002 No writer supplied for serializer
at java.lang.Throwable.<init>(Throwable.java:74)
at java.lang.Exception.<init>(Exception.java:38)
at java.lang.RuntimeException.<init>(RuntimeException.java:43)
at java.lang.IllegalStateException.<init>(IllegalStateException.java:41)
at org.apache.xml.serialize.XMLSerializer.startDocument
   (XMLSerializer.java:352)

This problem didn't occur in Xerces 1.0.3.

Here is a simple program to illustrate the problem:

import java.io.*;

import org.apache.xml.serialize.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
 
public class Serialize
{
        public static void main(String[] args) throws Exception
        {
                if (args.length < 1)
                {
                        System.out.println("Syntax: Serialize <filename>");
                        return;
                }

        OutputFormat of = new OutputFormat();
        of.setEncoding("iso-8859-1");
        of.setDoctype("null","foo.dtd");
        XMLSerializer serial =
            new XMLSerializer(new FileOutputStream(args[0]), of);

        serial.startDocument();

        serial.processingInstruction("acme", "hej på dig!");
        AttributeListImpl attrs = new AttributeListImpl();
        attrs.addAttribute("hej","CDATA","banan");
        attrs.addAttribute("id","ID","A123");
        serial.startElement("foo", attrs);
        serial.characters("foo bar".toCharArray(),0,7);
        serial.endElement("foo");

        serial.endDocument();
        }
}

P.S: I'm not subscribed to this mailing list, please answer by mail to
me (see the sig below).

-- 
/****************************************************************\
* You have just read a message from Mikael Ståldal.              *
*                                                                *
* Remove "-ingen-reklam" from the address before mail replying.  *
\****************************************************************/

Reply via email to