Yes, I understand that, currently, custom functions must pass in the context 
according to spec. That is inconsistent. If standard library functions can 
achieving it should not custom functions be allowed to do the same?

Mark

From: [email protected] 
[mailto:[email protected]] On Behalf Of Florent Georges
Sent: Thursday, February 04, 2010 4:58 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] context item within function calls

  Hi,

  A user function cannot access the context node.  You have to pass it 
explicitly.  Some functions in the standard library have this special power 
though.

  Regards,

--
Florent Georges
http://www.fgeorges.org/


________________________________
De : Mark Boyd <[email protected]>
À : General Mark Logic Developer Discussion <[email protected]>
Envoyé le : Ven 5 Février 2010, 0 h 42 min 57 s
Objet : [MarkLogic Dev General] context item within function calls
How do functions like fn:root and fn:string-length get access to the “context 
item” of the calling xquery code? For example, knowing that where the following 
function is called my context item will always have an attribute of “product” 
with a comma separated list of products to which the assembly applies, how can 
I write my functions like fn:root such that the parameter is optional and the 
context item is the default? Example:

declare function is-part-of(
 $assembly as xs:string?  <--- note optionality (sic) of this parameter
) as xs:boolean {
 if ($product)
  then fn:contains($assembly/@product, $product)
 else fn:contains(./@product, $product)  <--- note use of context node “.”
};

This results in:

[1.0-ml] XDMP-CONTEXT: (err:XPDY0002) Expression depends on the context where 
none is defined

But,

$assembly/@product[fn:string-length() > 10]

compiles and runs just fine. So how is this implemented?

Mark

Mark R. Boyd
Principle Engineer
ICS Department
The Church of Jesus Christ of Latter-Day Saints



NOTICE: This email message is for the sole use of the intended recipient(s) and 
may contain confidential and privileged information. Any unauthorized review, 
use, disclosure or distribution is prohibited. If you are not the intended 
recipient, please contact the sender by reply email and destroy all copies of 
the original message.


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to