xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald_Les...@lotus.com
Subject Re: Xalan + Xerces problem
Date Tue, 25 Jan 2000 16:43:14 GMT

I believe your problem is relying on the default DTM (Document Table Model,
a pseudo DOM representation that is faster but does not work directly with
DOM input) to work with a DOM node. When you instantiate the XSLTProcessor,
try specifying the liaison to the Xerces DOM parser, and I think your
problem will go away. In other words, replace

XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

     with

XSLTProcessor processor = XSLTProcessorFactory.getProcessorUsing
LiaisonName("org.apache.xalan.xpath.xdom.XercesLiaison");

If this does not fix your problem, please let me know! -- Don





Mats Norén <mats.noren@spectral.se> on 01/24/2000 11:26:35 PM

Please respond to general@xml.apache.org

To:   general@xml.apache.org
cc:    (bcc: Donald Leslie/CAM/Lotus)

Subject:  Re: Xalan + Xerces problem


The same result unfortunately... :-(

Brian Dupras wrote:

> > The row that seem to cause the problem is
> >
> > XSLTInputSource xmlID = new XSLTInputSource(doc);
>
> Just a guess, but try changing to :
>
> XSLTInputSource xmlID = new XSLTInputSource(doc.getDocumentElement());
>
> > -----Original Message-----
> > From: Mats Norén [mailto:mats.noren@spectral.se]
> > Sent: Monday, January 24, 2000 8:51 PM
> > To: general@xml.apache.org
> > Subject: Xalan + Xerces problem
> >
> >
> > Hi
> > I've just started using xalan and xerces...my idea is to create a
> > DOM-representation of various databasefields, do some calculations and
> > then process them with xalan...
> > Just to get started I rewrote some code from the xalandistribution and
> > tried to process it, however it didn't succeed.
> > When I run the class I get the following error:
> >
> > Exception in thread "main" DTMLiaison can not handle nodes of
> > typeclass
> > org.apache.xerces.dom.ElementImpl
> >         at org.apache.xalan.xslt.XSLTEngineImpl.
> >         at org.apache.xalan.xslt.XSLTEngineImpl.
> >         at org.apache.xalan.xslt.XSLTEngineImpl.
> >
> >         at transform.main(transform.java:114)
> >
> > The code looks like this:
> >
> > 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.XPathException;
> > import org.apache.xalan.xslt.XSLTEngineImpl;
> >
> > import org.apache.xalan.xpath.xml.TreeWalker;
> > import org.apache.xalan.xpath.xml.FormatterToXML;
> >
> > import org.apache.xerces.dom.*;
> >
> > import java.io.PrintWriter;
> > import java.io.FileWriter;
> > import java.io.BufferedReader;
> > import java.io.FileReader;
> > import java.io.Reader;
> > import org.w3c.dom.*;
> > import org.xml.sax.InputSource;
> > import org.xml.sax.SAXException;
> >
> > public class test
> >  {
> >      public static void main(String[] args)
> >       throws java.io.IOException,
> >              java.net.MalformedURLException,
> >              org.xml.sax.SAXException
> >      {
> >
> >   Document doc = new DocumentImpl();
> >   Element el = doc.createElement("legend");
> >   doc.appendChild(el);
> >   for (int i=0; i < 10; i++){
> >       Element child =  doc.createElement("text" + i);
> >       child.setAttribute("ID", "" + i);
> >       el.appendChild(child);
> >   }
> >
> >   XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
> >   XSLTInputSource xmlID = new XSLTInputSource(doc);
> >   XSLTInputSource stylesheetID = new XSLTInputSource("test.xsl");
> >   Document out = new 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);
> >
> > The row that seem to cause the problem is
> >
> > XSLTInputSource xmlID = new XSLTInputSource(doc);
> >
> > When I use the originalfrom with a reference to a file it works just
> > fine...
> > But I would like to create my own document within the class
> > and not load
> > it from file...
> >
> > Can anyone tell me how to do that ?
> >
> > /Mats
> >
> >
> >
> >









Mime
View raw message