RE: [xsl] Passing XML Tree to a java method as String.

Subject: RE: [xsl] Passing XML Tree to a java method as String.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 15 Jul 2006 06:27:24 +0100
> I have a SOAP Message in the XSL template and need to pass 
> everything inside the Body element to a java method that 
> takes a String.

You don't make it clear, but presumably the Java method is expecting lexical
XML containing markup (angle brackets)?

> 
> When I do the following:
> <xsl:template match="/">
> 	<xsl:variable name="myxml">
> 		<xsl:copy-of select="env:Envelope/env:Body/*" />
> 	</xsl:variable>
> 
> 	<xsl:value-of select="JavaClassRef:javaMethod($myxml)" 
> /> </xsl:template>
> 
> In the javaMethod I get only the values inside the elements passed.
> How can I pass everything including the elements that are 
> inside the Body element as String (the entire XML structure 
> as String)? Do I need to convert the XML to String?

Interfaces to extension functions are entirely implementation-defined, so it
all depends on the product. I would expect that most products, if they allow
you to pass a node to a function that expects a string, would convert the
node to a string by calling the string() function, which will lose all the
markup.

Saxon has an extension function saxon:serialize() which might be what you
want.

Michael Kay
http://www.saxonica.com/

Current Thread