Sorry about that. Line 634 of BaseMarkupSerializer should be changed
from
if ( publicId != null )
to
if ( publicId == null )
and it should fix the problem you reported. I'm adding two other fixes
and will update the CVS tomorrow.
arkin
Andy Clark wrote:
>
> I looked at the org.apache.xml.serialize classes for the first
> time today and I can't seem to get a simple XMLSerializer
> example to work. I keep getting NullPointerExceptions all over
> the place.
>
> Has anyone else seen these problems? Is it a usage problem?
> Perhaps we should have part of the documentation talk about
> how to use the new serializer APIs. Anybody interested in
> writing those docs?
>
> Also, I think I saw some bugs in the code. But I'd like to
> get an answer on whether I'm using them correctly before I
> start fixing bugs in the source.
>
> I've included the program below as well as the stack trace of
> the exception.
>
> // BEGIN Test.java
> package test;
>
> import org.apache.xerces.parsers.DOMParser;
>
> import org.apache.xml.serialize.Method;
> import org.apache.xml.serialize.OutputFormat;
> import org.apache.xml.serialize.Serializer;
> import org.apache.xml.serialize.SerializerFactory;
> import org.apache.xml.serialize.XMLSerializer;
>
> import org.w3c.dom.Document;
>
> public class Test {
>
> public static void main(String argv[]) throws Exception {
>
> DOMParser parser = new DOMParser();
> SerializerFactory factory =
> SerializerFactory.getSerializerFactory(Method.XML);
>
> for (int i = 0; i < argv.length; i++) {
> final String arg = argv[i];
> System.err.println("argv["+i+"]: "+arg);
> parser.parse(arg);
> Document document = parser.getDocument();
> OutputFormat format = new OutputFormat(document, "UTF-8", false);
> Serializer serializer = factory.makeSerializer(format);
> serializer.asDOMSerializer().serialize(document);
> }
>
> }
>
> }
> // END Test.java
>
> // BEGIN personal.xml
> <?xml version="1.0"?>
> <!DOCTYPE personnel SYSTEM "personal.dtd">
> <?xml-stylesheet type='text/xsl' href='personal.xsl'?>
> <personnel>
> <person id="H.MARUYAMA" >
> <name><family>MARUYAMA</family> <given>Hiroshi</given></name>
> <email>[EMAIL PROTECTED]</email>
> <link subordinates=" N.URAMOTO K.TAMURA "/>
> </person>
> <person id="N.URAMOTO">
> <name><family>URAMOTO</family> <given>Naohiko</given></name>
> <email>[EMAIL PROTECTED]</email>
> <link manager=" H.MARUYAMA"/>
> </person>
> <person id="K.TAMURA">
> <name>
> <family>TAMURA</family> <given>Kent</given>
> </name>
> <!-- This URL is mail address.-->
> <url href="mailto:[EMAIL PROTECTED]"/>
> <url href="mailto:[EMAIL PROTECTED]"/>
> <link manager="H.MARUYAMA"/>
> </person>
> </personnel>
> // END personal.xml
>
> // BEGIN personal.dtd
> <?xml encoding="US-ASCII"?>
>
> <!ELEMENT personnel (person)+>
> <!ATTLIST person note CDATA #IMPLIED
> contr (true|false) "false"
> id ID #REQUIRED>
> <!ELEMENT person (name,email*,url*,link?)>
> <!ELEMENT family (#PCDATA)>
> <!ELEMENT given (#PCDATA)>
> <!ELEMENT name (family,given?)>
> <!ELEMENT email (#PCDATA)>
> <!ELEMENT url EMPTY>
> <!ATTLIST url href CDATA "http://">
> <!ELEMENT link EMPTY>
> <!ATTLIST link
> manager IDREF #IMPLIED
> subordinates IDREFS #IMPLIED>
>
> <!NOTATION gif SYSTEM "photoshop.exe">
>
> <!ENTITY internal-entity "entity-value">
> <!ENTITY external-entity PUBLIC "-//ENTITY" "external-entity.ent">
> <!ENTITY unparsed-entity SYSTEM "unparsed-entity.ent" NDATA gif>
> // END personal.dtd
>
> // BEGIN Stack Trace
> Exception in thread "main" java.lang.NullPointerException:
> at
> org.apache.xml.serialize.BaseMarkupSerializer.printDoctypeURL(BaseMarkupSerializer.java:1261)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.unparsedEntityDecl(BaseMarkupSerializer.java:638)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:773)
> at
> org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:385)
> at test.Test.main(Test.java:27)
> // END Stack Trace
>
> --
> Andy Clark * IBM, JTC - Silicon Valley * [EMAIL PROTECTED]