[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Can I pass DOM from the Xalan XSLT processer to a Java

Subject: Can I pass DOM from the Xalan XSLT processer to a Java object?
From: "craig-xsl" <craig-xsl@xxxxxxxxxxxxxxx>
Date: Thu, 12 Jun 2003 16:29:38 -0400
passing object to xslt
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.