Saxon 8.1 and grouping in XQuery

| No Comments | No TrackBacks

Cafe con Leche XML News:

Michael Kay has released Saxon 8.1, an implementation of XSLT 2.0, XPath 2.0, and XQuery in Java. Saxon 8.1 is published in two versions for both of which Java 1.4 is required. Saxon 8.1B is an open source product published under the Mozilla Public License 1.0 that "implements the 'basic' conformance level for XSLT 2.0 and XQuery." Saxon 8.1SA is a £250.00 payware version that "allows stylesheets and queries to import an XML Schema, to validate input and output trees against a schema, and to select elements and attributes based on their schema-defined type. Saxon-SA also incorporates a free-standard XML Schema validator. In addition Saxon-SA incorporates some advanced extensions not available in the Saxon-B product. These include a try/catch capability for catching dynamic errors, improved error diagnostics, support for higher-order functions, and additional facilities in XQuery including support for grouping, advanced regular expression analysis, and formatting of dates and numbers."
Hmmm, grouping for XQuery... Here is how it looks like in Saxon-SA:
declare namespace f="f.uri";

(: Test saxon:for-each-group extension function :)

declare function f:get-country ($c) { $c/@country };

declare function f:put-country ($group) {
    <country name="{$group[1]/@country}" 
        leading="{$group[1]/@name}" size="{count($group)}">
       {for $g in $group 
           order by $g/@name
           return <city>{ $g/@name }</city>

         saxon:function('f:get-country', 1), 
         saxon:function('f:put-country', 1))}
Looks a bit convolute for me. More info here.

Related Blog Posts

No TrackBacks

TrackBack URL:

Leave a comment