[xquery-talk] XQuery 3.0 and maps in Saxon

Michael Kay mike at saxonica.com
Sat Jan 28 10:52:04 PST 2012

On 28/01/2012 16:56, Jakub Maly wrote:
> (At first, I apologize to the members of XSL list, from which I was referred here, for getting the same message twice).
> Hello,
> I would like to experiment with map features in Saxon (http://www.saxonica.com/documentation/expressions/xpath30maps.xml), but I am unable to get past query compilation. Maybe I am missing some parameter or I use a wrong namespace, but I just can't find the right answer.
I was rather hoping that the W3C spec would be out before the Saxon 
implementation, but it got held up because people in the XQuery WG 
didn't want it in XQuery 3.0. The net result is that there's a shortage 
of documentation.

The page at http://www.saxonica.com/documentation/extensions/map.xml 
wrongly gives the namespace as "http://ns.saxonica.com/map". In fact, in 
the over-optimistic belief that the spec was about to be approved by 
W3C, I moved the functions into the namespace 
> This is my query code:
> xquery version "3.0";
> (: i have also tried http://www.w3.org/2005/xpath-functions/map, no difference :)
> import module namespace map = "http://ns.saxonica.com/map";
> map:get(map { 1 := 'aaa'}, 1)
For vendor-defined extension functions in Saxon, you don't need an 
import module, but you do need to declare the namespace. So it should be

xquery version "3.0";
declare namespace map := "http://www.w3.org/2005/xpath-functions/map";
map:get(map { 1 := 'aaa'}, 1)

Michael Kay

More information about the talk mailing list