xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mats Norén <mats.no...@spectral.se>
Subject Xalan + Xerces problem
Date Tue, 25 Jan 2000 03:50:38 GMT
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
        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,

  Document doc = new DocumentImpl();
  Element el = doc.createElement("legend");
  for (int i=0; i < 10; i++){
      Element child =  doc.createElement("text" + i);
      child.setAttribute("ID", "" + i);

  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);

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
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 ?


View raw message