You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Wolf-Dieter Klotz <kl...@esrf.fr> on 2000/02/25 13:24:06 UTC
Xalan: TransformToDom problem
Hi
I downloaded recently 'xalan_0_19_4.jar' and 'Xerces-J-bin.1.0.1.jar'
and installed everything
on my Solaris 7(sparc). When going through the xalan-samples I get:
(vol)$echo $CLASSPATH
/home/klotz/XML,HTML,CSS/Xalan/xalan.jar:/home/klotz/XML,HTML,CSS/Xalan/xerces.jar:/home/klotz/XML,HTML,CSS/Xalan/xalansamples.jar
(vol)$java -version
java version "1.1.6"
(vol)$java TransformToDom
XSL Error: Can't use a DTMLiaison for an output DOM node... pass a
org.apache.xalan.xpath.xdom.XercesLiaison instead!
XSL Error: SAX Exception
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at org.xml.sax.SAXException.<init>(Compiled Code)
at org.apache.xalan.xpath.XPathException.<init>(Compiled Code)
at org.apache.xalan.xslt.XSLProcessorException.<init>(Compiled
Code)
at org.apache.xalan.xslt.XSLTEngineImpl.error(Compiled Code)
at org.apache.xalan.xslt.StylesheetRoot.process(Compiled Code)
at org.apache.xalan.xslt.XSLTEngineImpl.process(Compiled Code)
at TransformToDom.main(Compiled Code)
(vol)$
The sample's source I use is TransformToDom.java (unmodified!):
:
:
import org.apache.xalan.xslt.XSLTProcessor;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xpath.xml.TreeWalker;
import org.apache.xalan.xpath.xml.FormatterToXML;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Reader;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Simple sample code to show how to run the XSL processor
* from the API, to create a DOM, and then print the DOM
* to System.out.
*/
public class TransformToDom
{
public static void main(String[] args)
throws java.io.IOException,
java.net.MalformedURLException,
org.xml.sax.SAXException
{
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
XSLTInputSource xmlID = new XSLTInputSource("foo.xml");
XSLTInputSource stylesheetID = new XSLTInputSource("foo.xsl");
Document out = new org.apache.xerces.dom.DocumentImpl();
XSLTResultTarget resultTarget = new XSLTResultTarget(out);
processor.process(xmlID, stylesheetID, resultTarget);
PrintWriter pw = new PrintWriter( System.out );
FormatterToXML fl = new FormatterToXML(pw);
TreeWalker tw = new TreeWalker(fl);
tw.traverse(out);
}
}
Any idea what to do ????
--
W.-D. Klotz --- European Synchrotron Radiation Facility (ESRF)
6, rue Jules Horowitz, BP 220
38043 Grenoble, CEDEX 9, FRANCE
TEL:+33(0)4.76.88.20.44, FAX:+33(0)4.76.88.24.27