You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Brian Dupras <br...@centera.com> on 2000/01/17 19:24:50 UTC

xslt with existing DOM nodes

I'm trying to use xalan to transform an xml element using an xslt stylesheet
already loaded as a dom node.  However, I get this:  "DTMLiaison can not
handle nodes of typeclass org.apache.xerces.dom.DeferredElementImpl"

In the final version of the program, I'll be getting xml as strings and I
will have processed the xml nodes a bit before this point.  So it's
important that I be able to use existing DOM Nodes as the input to the
processor.

Am I doing something wrong? (code below)

xerces 1.0.1
xalan  0.19.2
Java   1.2.2

Brian Dupras



In the following code, the getxml() function loads an xml document off the
disk.  This is a stand-in for when we'll be getting xml as strings from a
server object.  

Here's example code:

try{
	Document xmldocResult = new DocumentImpl();
	Element xml = getxml("a.xml");
	Element xsl = getxml("b.xsl");
	xsltProcessor.process(new XSLTInputSource(xml), 
				new XSLTInputSource(xsl), 
				new XSLTResultTarget(xmldocResult)
				);
	debugout("transform passed: " +
xmldocResult.getDocumentElement().getNodeName());
} catch (Exception e) {
	//right now, this error is always blown
	debugout("error in transform\n" + e); 
}


private Element getxml(String fn) 
	throws SAXParseException, SAXException, IOException
{
	DOMParser domParser =
(DOMParser)Class.forName("org.apache.xerces.parsers.DOMParser").newInstance(
);
	domParser.parse(strRoot + fn);
	return domParser.getDocument().getDocumentElement();
} //getxml(String)



p.s.  I've tried passing in the Document as well as the getDocumentElement()
for the xsl parameter.



Brian Dupras
Centera Information Systems, Inc.
phone	303.939.0200 x294
fax	303.939.0111
web	http://www.centera.com
email	briand@centera.com