Hi Tim, Put your permissions into a map:map, or put all your args into it, and pass that through to the eval. That is the only safe way to pass through sequences..
Kind regards, Geert > -----Oorspronkelijk bericht----- > Van: [email protected] [mailto:general- > [email protected]] Namens Tim Finney > Verzonden: woensdag 24 april 2013 7:20 > Aan: MarkLogic Developer Discussion > Onderwerp: Re: [MarkLogic Dev General] How to pass complex type into > xdmp:eval? > > Mike, > > Sorry, I should have added that I might want to use options with > xdmp:eval. E.g. > > my:doc-perms-set($URI, $perms, $DB) { > let $query := ... > let $args := ... > let $options := <options xmlns="xdmp:eval"> > <database>{xdmp:database($DB)}</database> > </options> > return xdmp:eval($URI, $perms, $options) > }; > > Tim > > On 04/24/2013 01:13 PM, Michael Blakeley wrote: > > Why call eval? > > > > -- Mike > > > > On Apr 23, 2013, at 21:41, Tim Finney <[email protected]> wrote: > > > >> Hi Everyone, > >> > >> Say I have an amped function to set doc permissions. E.g. > >> > >> declare function my:document-set-permissions( > >> $URI as xs:string, > >> $permissions as element()* > >> ) as empty-sequence() { > >> try { > >> let $query := ' > >> declare variable $URI external; > >> declare variable $permissions external; > >> xdmp:document-set-permissions($URI, $permissions) > >> ' > >> let $args := ( > >> fn:QName("", "URI"), $URI, > >> fn:QName("", "permissions"), $permissions > >> ) > >> return xdmp:eval($query, $args) > >> } > >> catch ($e) { fn:error(xs:QName("e:fail"), "operation failed", $e) } > >> }; > >> > >> I call this like so: > >> > >> let $URI := "myURI" > >> let $permissions := ( > >> xdmp:permission("app-user", "read"), > >> xdmp:permission("app-user", "update") > >> ) > >> return my:document-set-permissions($URI, $permissions) > >> > >> However, I get this error which is caused by fn:data which is presumably > >> called by xdmp:eval. > >> > >> XDMP-NONMIXEDCOMPLEXCONT 1.0-ml Node has complex type with > non-mixed > >> complex content XDMP-NONMIXEDCOMPLEXCONT: > fn:data(<sec:permission > >> > xmlns:sec="http://marklogic.com/xdmp/security"><sec:capability>update< > /sec:capability><sec:role-id>...</sec:permission>) > >> > >> > >> Is there a way to pass in the permissions elements? > >> > >> Best, > >> > >> Tim Finney > >> _______________________________________________ > >> General mailing list > >> [email protected] > >> http://developer.marklogic.com/mailman/listinfo/general > >> > > _______________________________________________ > > General mailing list > > [email protected] > > http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
