[xquery-talk] xquery extension function for xslt

Andrew Welch andrew.j.welch at gmail.com
Wed Sep 5 11:14:10 PDT 2007

On 9/5/07, Michael Kay <mike at saxonica.com> wrote:
> > I've knocked together a quick n dirty xquery extension
> > function for use with eXist and Saxon and included it in Kernow.
> Saxon already has the ability for an XSLT stylesheet to import an XQuery
> library module and invoke the functions defined in it. I'm not convinced
> that the ability to execute the main query expression adds very much.

Say you've got an XML database containing GB's of articles and you
want to generate an index where each article title is grouped by
letter and then sorted within each group.

XSLT is my tool of choice, as I know it's straightforward to do the
grouping and sorting, and a nice way to generate my HTML index pages.

The bottleneck is collecting together all of the <title>s - I've done
this using both the collection() + saxon:discard-document() technique
on the filesystem, and using eXist's rest API.... the latter is
obviously far faster than the former, usually this is a batch process
so it's no big deal, but improving turn around time is always a goal.

It would be fantastic to improve on this where XQuery does the
selection, and XSLT does the result processing (you could almost say
the presentation).

The only reason I'm talking about providing an entire XQuery to the
XQuery engine is that I don't know any better, if its possible to get
the nodes out of the database in an equally fast way then great.  I'm
coming at this from the high-level feature request end :)

Another use-case that I do often is adhoc reporting on the data -
given 1000s of articles give me all articles that aren't linked to by
any of the others, or the articles that are linked to most.
Extracting all the links out of the articles should be fastest in
XQuery, organising and presenting that data is best tackled in XSLT.

So basically the request is to make the entire result set from a query
available to XSLT 2.0.     (It doesn't necessarily have to be by
invoking the query from within the XSLT, that's just the way I've
approached it and at the moment the most appealing)

Andrew Welch
Kernow: http://kernowforsaxon.sf.net/

More information about the talk mailing list