You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by za...@netscape.net on 2003/01/24 20:01:15 UTC

DOM support in XSLTC java extension

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? 

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?

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.

Thanks for any hints,
zak :-)


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

Re: DOM support in XSLTC java extension

Posted by Santiago Pericas-Geertsen <Sa...@sun.com>.
> 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