[xquery-talk] modules and context

Michael Kay mhk at mhk.me.uk
Fri Nov 18 16:16:45 PST 2005


You can pass in the document as a parameter to the function, or you can make
it a global variable.

(The same is true in XSLT 2.0 functions)

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Dave Pawson
> Sent: 18 November 2005 15:48
> To: talk at xquery.com
> Subject: [xquery-talk] modules and context
> 
> I've written a function in a module,
> and I'm getting the error
> XPDY0002: Cannot select a node here: the context item is undefined
> 
> How do I ... pass in the / context  of a document please,
> or do I have to open it with doc('a.xml') again?
> 
> TIA
> 
> Module - failing - is below
> 
> xquery version "1.0";
> module namespace dp ="urn:modul";
> declare namespace db ="http://docbook.org/ns/docbook";
> declare namespace rng = "http://relaxng.org/ns/structure/1.0" ;
> 
> declare function dp:gatts($attributes as xs:string)
> {
> for $att in //rng:define[@name=$attributes]
> return
> <att>{$att}</att>
> };
> 
> 
> 
> 
> --
> Dave Pawson
> XSLT XSL-FO FAQ.
> http://www.dpawson.co.uk
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 




More information about the talk mailing list