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

xPath function in xslt 3.0

Subject: xPath function in xslt 3.0
From: "Leo Studer leo.studer@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Dec 2018 18:21:17 -0000
 xPath function in xslt 3.0
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)
};

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.