It all depends on what is inside of $x ! This case wont work: xdmp:eval($x, (xs:QName("x"), "world"))
unless $x contains a external variable declaration for $x Example: let $x := "1 + 1" return xdmp:eval($x) ==> 2 But this doesnt do what you want really .. let $x := "1 + 1" return xdmp:eval($x, (xs:QName("x"), "world")) ==> 2 This does: (but warning the use of $x in 2 contexts is humanly confusing. let $x := "declare variable $x external; $x" return xdmp:eval($x, (xs:QName("x"), "world")) ==> "world" ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation d...@marklogic.com Phone: +1 812-482-5224 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Pascal Cadet Sent: Wednesday, October 17, 2012 9:36 AM To: Mike Sokolov Cc: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Eval and invoke: set the context item? Hi, Try this ways : - xdmp:value("$x") - xdmp:eval($x, (xs:QName("x"), "world")) Pascal 2012/10/17 David Lee <david....@marklogic.com<mailto:david....@marklogic.com>> for $x in //x return xdmp:eval ($x) ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation d...@marklogic.com<mailto:d...@marklogic.com> Phone: +1 812-482-5224<tel:%2B1%20812-482-5224> Cell: +1 812-630-7622<tel:%2B1%20812-630-7622> www.marklogic.com<http://www.marklogic.com> -----Original Message----- From: Mike Sokolov [mailto:soko...@ifactory.com<mailto:soko...@ifactory.com>] Sent: Wednesday, October 17, 2012 9:24 AM To: MarkLogic Developer Discussion Cc: David Lee; Florent Georges Subject: Re: [MarkLogic Dev General] Eval and invoke: set the context item? On 10/16/2012 03:07 PM, David Lee wrote: > In MarkLogic the context item is the entire database, it isnt settable. > > > -------------------------- Just to expand a little on that, that's true for outermost expressions, but there is a context item for every expression, and since xdmp:eval() may occur within another expression, it's a reasonable question whether its enclosing context is available or not: for $x in //x return xdmp:eval ("$x") but the answer is no ... XDMP-UNDVAR: (err:XPST0008) Undefined variable $x and I guess there is no way to provide it? _______________________________________________ General mailing list General@developer.marklogic.com<mailto:General@developer.marklogic.com> http://developer.marklogic.com/mailman/listinfo/general -- Pascal CADET 06 12 97 02 53 www.pressinnov.com<http://www.pressinnov.com>
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general