[xquery-talk] Looking for an example - calling XQuery 3.0 function module from XSLT 3.0

Michael Kay mike at saxonica.com
Mon Feb 4 01:23:15 PST 2013


Here's a very simple test case from my test suite (though it uses XSLT 
2.0 and XQuery 1.0):

test.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="2.0"
xmlns:saxon="http://saxon.sf.net/" xmlns:qf="library.uri">

<xsl:template match="/">
<out>
   <xsl:value-of select="qf:distinct-countries(.)"/>
</out>
</xsl:template>

<saxon:import-query href="test.xq" namespace="library.uri"/>

</xsl:stylesheet>

test.xq:

xquery version "1.0";
module namespace qf = "library.uri";
declare function qf:distinct-countries($root as document-node()) as 
xs:string* {
   distinct-values($root//city/@country)
};

One word of advice, I would advise avoiding use of global variables in 
the query library. There are some unresolved bugs relating to use of 
global variables in separately compiled query libraries.

I would also suggest, if you're having problems, it's best to say what 
you are doing and how it is failing. That way, it's easier to see where 
you are stuck and what information you need to help you move forward. 
It's even possible you've hit a bug - you're a little off-piste when you 
use extensions like this, so the risk of finding bugs is greater.

Michael Kay
Saxonica


On 01/02/2013 15:10, Loren Cahlander wrote:
> Hello folks,
>
> I am playing with the latest version of Saxon from Saxonica and am looking for an example of calling a function from an XQuery 3.0 function module from XSLT 3.0.  Has anyone out there done this yet?
>
> Thanks,
> Loren
>
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>



More information about the talk mailing list