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

RE: Calling a java method in XSL 1.0 with Saxon 6.5.5

Subject: RE: Calling a java method in XSL 1.0 with Saxon 6.5.5 fails
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 16 May 2007 09:01:04 +0100
RE:  Calling a java method in XSL 1.0 with Saxon 6.5.5
> I have a (currently) simple java method I want to use in a 
> xsl stylesheet. I use XSL 1.0 and Saxon 6.5.5 (project 
> requirement :'( ).

Please tell whoever it is that sets your project requirements that Saxon
6.5.5 is getting rather old, that its developer no longer remembers very
much about how it works, and that Saxon 8.9.0.3 handles XSLT 1.0 stylesheets
just as well if not better, unless you use one of the very few pathological
constructs where the specification changes incompatibly in XSLT 2.0.

However, I've opened up the source code for the first time in many months,
to see what exactly the message means. As far as I can see, you can only get
this message if the supplied type of one of the arguments to the extension
function is an XPath string, and the declared type of the parameter in the
Java method is org.w3.dom.NodeList.

Is it possible that it's trying to call a different version of your method?
It looks to me as if the version you've shown us is essentially a diagnostic
method that's simply there to display the types of the arguments it has been
given. This isn't actually a very effective diagnostic in the first place,
because the conversions that Saxon performs will depend on the declared
types of the parameters to the method. My theory is that you had a different
version of the method before you wrote the diagnostic version, and it's that
that's being called.

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

> This is the class I want to call (the signature is not final, 
> just because I want it running at all now):
> 
> public class LineSplitter {
> 
>     public static Object splitIntoLines(Object nodes, Object 
> lineLengths) {
>         return new String(nodes.getClass().getCanonicalName() + "\n"
>                 + lineLengths.getClass().getCanonicalName());
>     }
> }
> 
> 
> and this is the template I want to use it with:
> 
>     <xsl:template name="splitIntoRows">
>         <xsl:param name="nodes"/>
>         <xsl:param name="linelengths"/>
>         <xsl:value-of select="splitter:splitIntoLines($nodes, 
> $linelengths)"
>             xmlns:splitter="java:xxx.xslextension.LineSplitter"/>
>     </xsl:template>
> 
> 
> While debugging this method in Oxygen Eclipse Plugin I get 
> following error:
> 
>     Conversion of string to org.w3c.dom.NodeList is not supported
> 
> I'm not converting anything as I think. What is going wrong here?
> 
> Kind regards,
> Kai

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-2011 All Rights Reserved.