[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Michael Kay wrote:
Re: [xsl] Calling java in xsl.
Subject: Re: [xsl] Calling java in xsl. From: Kamal Bhatt <kbhatt@xxxxxxxxx> Date: Wed, 15 Feb 2006 08:37:03 +1100 |
Michael Kay wrote:
Thanks for that. Mainly for my own curiousity, how do we make this call directly in 2.0?<xsl:variable name="todayPlus" select="cal:add($today, 6, $offset)"/>
Now, what bothers me about this is the variable todayPlus which serves no purpose other than giving us an opportunity to call add. How can we avoid this useless call?
You're right to be bothered: if Saxon were executing this, it would decide that the variable served no useful purpose, and wouldn't evaluate it. Even if it were evaluated, the order of evaluation is not guaranteed.
Of course in XSLT 2.0 you can do this calculation within the language, so the problem wouldn't arise. But if you do need to call extension functions for their side-effects rather than their result, my usual advice is to use a construct where the result appears to be used. In many cases the Java method returns void, so (in Saxon at any rate) you can do
<xsl:sequence select="cal:add($today, 6, $offset)"/>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Calling java in xsl., Michael Kay | Thread | RE: [xsl] Calling java in xsl., Michael Kay |
[xsl] How to pass a node set or RTF, Quincy Lu \(u\) | Date | [xsl] possible nested loops, garry |
Month |
Keywords