Hi
I have seen that using the xmlns:java="http://xml.apache.org/xslt/java" it is
possible to invoke methods on java objects from within an XSL
template, for example:
<xsl:template match="/language/text()">
<!-- invoke a static method passing in the text node -->
<xsl:value-of select="java:com.LSLocale.getJavaString(.)" />
</xsl:template>
Is it possible to pass actual DOM from the XSL processor back to a java
object? An article at Javaworld.com
http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-xslt-p2.html
states that "Any Xalan extension function can also take NodeLists or Nodes as
arguments and return these types to the XSLT processor". The article
demonstrates passing a Node to the XSLT processor but not taking one as an
argument as I am trying. So I tried:
<-- object instance reference -->
<xsl:param name="DOMExtractor" />
<xsl:variable name="tree">
<a>
<b>
<c>
<d/>
</c>
</b>
</a>
</xsl:variable>
<xsl:template match="root/blah/" >
<!-- pass the node to the object -->
<xsl:value-of select="java:setDataValue( $DOMExtractor, $tree )" />
</xsl:template>
Indeed I end up getting back is a org.w3c.dom.traversal.NodeIterator,
specifically a org.apache.xml.dtm.ref.DTMNodeIterator.
But when I call the NodeIterator methods to get a Node such as getRoot(), or
nextNode() NullPointers are thrown. I could cast to the DTMNodeIterator but
I have examined the object & it appears to be a flat representation of the
tree, not DOM.
Anyone know if there a way to get a DOM Element out of xalan?
I'm using
Xalan 2.4.D1
jdk 1.3.1
Thanks,
Craig
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list