[xquery-talk] modules and context

Martin Probst martin at x-hive.com
Fri Nov 18 17:32:04 PST 2005


> 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?

Well, the idea of a module is to contain reusable, context independent
functions, isn't it? You should pass the document as a parameter, e.g. 

> declare function dp:gatts($context as document-node(),
>                           $attributes as xs:string) as element()
> {
> for $att in $context//rng:define[@name=$attributes]
> return
> <att>{$att}</att>
> };

Martin



More information about the talk mailing list