You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Geoffrey Shuetrim <ge...@galexy.net> on 2005/05/31 15:18:41 UTC

Trouble getting the serializer to work in the DOM2DOM example

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".




Re: Trouble getting the serializer to work in the DOM2DOM example

Posted by Brian Minchau <mi...@ca.ibm.com>.
Geoffrey,
this sounds like a classpath issue, where some newer classes are being
picked up from a jar you've put on the classpath ( xalan.jar) but other
classes, with the same name,
effectively from an older version of xalan.jar are packaged in the JRE 1.4.
The result is that you are running an inconsistent set of classes. See
http://xml.apache.org/xalan-j/faq.html#faq-N100CC.


- Brian
- - - - - - - - - - - - - - - - - - - -
Brian Minchau
XSLT Development, IBM Toronto
e-mail:        minchau@ca.ibm.com



                                                                           
             Geoffrey Shuetrim                                             
             <geoff@galexy.net                                             
             >                                                          To 
                                       xalan                               
             05/31/2005 09:18          <xa...@xml.apache.org>      
             AM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         Trouble getting the serializer to   
                   geoff               work in the DOM2DOM example         
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




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".