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