|
Subject: Re: [xsl] xPath function in xslt 3.0 From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 10 Dec 2018 18:55:45 -0000 |
It works for me, changing only the invocation of the function in
match="preis".
Perhaps the content of the "preis" element is not xs:double or
xs:untypedAtomic.
Michael Kay
Saxonica
> On 10 Dec 2018, at 18:21, Leo Studer leo.studer@xxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello
>
> The function below is working well in xQuery 3.0 but not in xslt 3.0
(Saxon-EE 9.8.0.12 in Oxygen) where it returns NaN. I cannot see the problem?
> Any suggestion?
>
> Thanks in advance
> Leo
>
>
> <xsl:variable name="exchangeRate" select="function ($fromCurrency as
xs:string, $toCurrency as xs:string) as xs:double{
> if ($fromCurrency = $toCurrency) then 1.0 else
> number(doc(concat('http://www.floatrates.com/daily/',$fromCurrency,'.xml
<http://www.floatrates.com/daily/',$fromCurrency,'.xml>'))
> //item[baseCurrency=$fromCurrency and
targetCurrency=$toCurrency]/exchangeRate)
> }"/>
>
> <xsl:template match="preis">
> <xsl:value-of select="$exchangeRate('USD','CHFb) * ."/>
> </xsl:template>
>
>
>
>
> Whereas in xQuery the same function works as it is expected
> declare variable $exchangeRate := function ($fromCurrency as xs:string,
$toCurrency as xs:string) as xs:double{
> if ($fromCurrency = $toCurrency) then 1.0 else
> number(doc(concat('http://www.floatrates.com/daily/
<http://www.floatrates.com/daily/>',$fromCurrency,'.xml'))
> //item[baseCurrency=$fromCurrency and
targetCurrency=$toCurrency]/exchangeRate)
> };
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] xPath function in xslt 3.0, Leo Studer leo.stude | Thread | [xsl] Confusion with the results of, Bridger Dyson-Smith |
| [xsl] xPath function in xslt 3.0, Leo Studer leo.stude | Date | [xsl] Confusion with the results of, Bridger Dyson-Smith |
| Month |