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

Re: Saxon extension functions

Subject: Re: Saxon extension functions
From: Michel Hendriksen <michel.hendriksen@xxxxxxxxx>
Date: Fri, 10 Dec 2010 15:33:12 +0100
Re:  Saxon extension functions
Thnx. I guess some samples on the net could use an update.

Michel

On Fri, Dec 10, 2010 at 3:04 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> In XSLT 2.0, a call to an unknown function is a static error even if the
> call is never executed. You need to do the test in use-when, which operates
> at compile time:
>
> <xslt:template name="seed">
>  <xslt:value-of use-when="function-available('date:new') and
>           function-available('date:get-time')"
> xmlns:date="java:java.util.Date"
>      select="date:get-time(date:new())"/>
>
>  <xslt:value-of use-when="not(function-available('date:new') and
>           function-available('date:get-time'))"
> xmlns:date="java:java.util.Date"
>      select="seconds-from-duration(current-time() - xs:time('00:00:00'))"/>
>
> </xslt:template>
>
> Michael Kay
> Saxonica
>
>
> On 10/12/2010 12:38, Michel Hendriksen wrote:
>>
>> Hi all,
>>
>> New topic. I made an extension function which is working in SaxonB.
>> When porting this to SaxonHE, where it is not supported, I get an
>> error that a matching function cant be found. This is expected. But
>> I'm testing for support of this and that seems to pass. So how do I
>> test for existing support? See my code below.
>>
>> <xslt:template name="seed">
>>        <!-- Works with SaxonB only! -->
>>        <xslt:choose>
>>                <xslt:when test="function-available('date:new') and
>> function-available('date:get-time')" xmlns:date="java:java.util.Date">
>>                        <xslt:variable name="date" select="date:new()"/>
>>                        <xslt:value-of select="date:get-time($date)"/>
>>                </xslt:when>
>>                <xslt:otherwise>
>>                        <!-- NOT random at all.....to be replaced by
>> something else -->
>>                        <xslt:variable name="time" select="current-time()"
>> />
>>                        <xslt:value-of select="seconds-from-time($time) +
>> 60 *
>> minutes-from-time($time) + 3600 * hours-from-time($time)"/>
>>                </xslt:otherwise>
>>        </xslt:choose>
>> </xslt:template>
>>
>> Error
>>
>> Error at xslt:variable on line 64 column 52 of selector.xsl:
>>   XPST0017 XPath syntax error at char 0 on line 64 in {date:new()}:
>>     Cannot find a matching 0-argument function named
>> {java:java.util.Date}new(). Note that
>>   direct calls to Java methods are not available under Saxon-HE
>> Error at xslt:value-of on line 65 column 50 of selector.xsl:
>>   XPST0017 XPath syntax error at char 0 on line 65 in
>> {date:get-time($date)}:
>>     Cannot find a matching 1-argument function named
>> {java:java.util.Date}get-time(). Note
>>   that direct calls to Java methods are not available under Saxon-HE
>>
>> line 64/65 are
>>
>>                        <xslt:variable name="date" select="date:new()"/>
>>                        <xslt:value-of select="date:get-time($date)"/>
>>
>> So within test.
>>
>> Michel Hendriksen
>> Kensas bv

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.