The variable $dir is not in scope for the xdmp:eval. Any variables for the eval'ed XQuery must be passed in as external variables on the call to xdmp:eval().
In this case, since $dir is a simple string, you could probably substitute it into the string that's being eval'ed. 'for $i in xdmp:directory("' || $dir || '") return document-uri($i)' On Jul 8, 2013, at 10:56 AM, sini narayanan <sini.isonl...@gmail.com> wrote: > Hi All, > > Why am I getting error message "XDMP-UNDVAR: (err:XPST0008) Undefined > variable $dir", when $dir is in scope? > I'm not able to identify the issue here. Please help. > > Code: > > declare function local:testFunct($input-document as xs:string) > { > if(contains($input-document, ".xml")) > then( > let $dir := if(doc($input-document)//@type/string() eq '2') then > '/type/shared/' > else '/type/common/' > for $type in xdmp:eval('for $i in xdmp:directory($dir) return > document-uri($i)' , (), > <options xmlns="xdmp:eval"> > <database>{xdmp:database("Modules")}</database> > </options>) > let $result := xdmp:invoke($type, > (xs:QName("var"), $input-document), > <options xmlns="xdmp:eval"> > <modules>{xdmp:modules-database()}</modules> > <root>/</root> > </options>) > > return > $result > ) > else() > }; > > Thanks, > Sini > _______________________________________________ > General mailing list > General@developer.marklogic.com > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general