I am trying to get the DOM2DOM.java Xalan usage example to work and am
running into the following error message:
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.xml.utils.TreeWalker.<init>(Lorg/xml/sax/ContentHandler;Lorg/apache/xml/utils/DOMHelper;)V
at org.apache.xml.serializer.ToStream.serialize(ToStream.java:211)
at net.galexy.trax.DOM2DOM.main(DOM2DOM.java:99)
This is identical to the kind of problem that I have been having in
using the Xalan serializer for my own serialization of HTML DOM objects.
I am having trouble even understanding this error message. I am
guessing that the version of Xalan that I am using is mismatched to the
DOM2DOM example code but the xalan.jar that I am using is 2.6.0 and the
DOM2DOM example is straight out of the public CVS.
Any hints on where I am going wrong with this serialization would be
most helpful.
Cheers
Geoff Shuetrim
PS:
The code I am using and having fail is as follows (in case it helps
diagnosis):
public void serialize(OutputStream outputStream,Document document,String
type) throws Exception {
java.util.Properties xmlProps =
OutputPropertiesFactory.getDefaultMethodProperties(type);
xmlProps.setProperty("indent", "yes");
xmlProps.setProperty("standalone", "no");
System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");
Serializer serializer =
SerializerFactory.getSerializer(xmlProps);
serializer.setOutputStream(outputStream);
serializer.asDOMSerializer().serialize(document);
}
The type parameter is generally one of "xml" or "html".