> Hi, > > I'm trying to port XSLTC maps with Java extensions from Saxon to XSLTC 2.4.1. I'm running into trouble with DOM use inside the extension java code. After receiving a NodeList as a parameter of the java extension method, I use item(0) to extract an Element object, but all I get is an org.apache.xalan.xsltc.dom.DOMImpl$NodeImpl object with node type ELEMENT_NODE. This class implements Node, but I need Element. > > Is this as expected/designed or am I doing something wrong?
Yes, that is expected. What your getting is a wrapper class that implements the Node interface containing a single node (represented as an int by XSLTC). > > I am using xsltc.jar of Xalan 2.4.1 with xalan.jar of Xalan 2.0.1; could this be the cause? I heard that XSLTC is generally independent of Xalan, but extensions could be an issue. Can anybody elaborate on this? > XSLTC implements only a subset of the extensions available in Xalan. Please refer to: http://xml.apache.org/xalan-j/extensions_xsltc.html > Is there a workaround to get an Element object? I need access to various methods in the DOM interface because we do quite a bit of navigating the DOM tree inside the extension. I am already thinking of writing a wrapper around the NodeImpl class implementing the Element interface, but that would get ugly. > Not sure what you need from the Element interface, but it looks like you'd need to extend this mechanism. One possible way would be to modify DOMImpl.makeNode(int) to look at the type of the node and create an instance of a class implementing the corresponding W3C interface. A similar change would be needed in methods like DOMImpl.makeNodeList(). The type of the formal argument in your extension method would be the same, but a downcast would do the trick if this is implemented. Hope this helps. -- Santiago
