<div dir="ltr"><div>Hi all, </div><div><br></div><div>I'm struggling with getting a working example of the following problem: I'm sending a query to an API that returns some data and, if the data set is large enough, a resumption token to requery the API.</div><div><br></div><div>I'm stuck at the point of how to generate the new query URL, while still processing the new data. Is the best idea to create a function that will update a new request to the API, or is there a different approach that can be used? </div><div><br></div><div>I've made several attempts with functions -- the latest non-working examples are below -- and I'm missing... something, but I don't know what. </div><div><br></div><div>Thanks for any guidance you can provide.</div><div>Cheers,<br>Bridger</div><div><br></div><div>(: sample query :)</div><div>(: <a href="http://server:8080/fedora/objects?query=pid~%7B$collection%7D*&resultFormat=xml&pid=true" target="_blank">http://server:8080/fedora/objects?query=pid~{$collection}*&resultFormat=xml&pid=true</a> :)</div><div><br></div><div>declare variable $query external := '<a href="http://our.server:8080/fedora/objects?query=pid~gamble*&amp;resultFormat=xml&amp;pid=true" target="_blank">http://our.server:8080/fedora/objects?query=pid~gamble*&amp;resultFormat=xml&amp;pid=true</a>';</div><div>declare variable $sessionToken := '&amp;sessionToken=';<br></div><div><div>declare variable $resToken := '';</div></div><div><br></div><div><div>(:functions:)</div><div>(:doesn't work:)</div><div>declare function local:getPID($in as document-node()) as xs:anyAtomicType*</div><div>{</div><div>  data($in/*:resultList/*:objectFields/*:pid)</div><div>};</div><div><br></div><div>(:doesn't work:)</div><div>declare function local:reQuery(</div><div>  $in as document-node(),</div><div>  $rQ as xs:untypedAtomic*) as document-node()</div><div>{</div><div>  let $rQ := $in/*:listSession/*:token/text()</div><div>  return (</div><div>    if ($rQ) then</div><div>      local:getPID(doc("$in" || "&amp;sessionToken=" || "$rQ"))</div><div>    else ()</div><div>  )</div><div>};</div></div><div><br></div><div>(: this works processing the descendant elements but doesn't recurse :)</div><div>for $result in fn:doc($query)/*:result</div><div><div>let $resToken := $result/*:listSession/*:token/text()</div><div>let $pid := $result/*:resultList/*:objectFields/*:pid/text()</div><div>return (</div><div>  $result,</div><div>  $resToken,</div><div>  $pid</div><div>)</div></div><div><br></div><div>(: sample returned from query; e.g. $result :)</div><div><div><result xmlns="<a href="http://www.fedora.info/definitions/1/0/types/" target="_blank">http://www.fedora.info/definitions/1/0/types/</a>" xmlns:types="<a href="http://www.fedora.info/definitions/1/0/types/" target="_blank">http://www.fedora.info/definitions/1/0/types/</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>" xsi:schemaLocation="<a href="http://www.fedora.info/definitions/1/0/types/" target="_blank">http://www.fedora.info/definitions/1/0/types/</a> <a href="http://localhost:8080/fedora/schema/findObjects.xsd" target="_blank">http://localhost:8080/fedora/schema/findObjects.xsd</a>"></div><div>  <listSession></div><div>    <token>63c0762b5eb3d4b46c58add843b7b3e6</token></div><div>    <cursor>0</cursor></div><div>    <expirationDate>2016-01-18T01:40:05.381Z</expirationDate></div><div>  </listSession></div><div>  <resultList></div><div>    <objectFields></div><div>      <pid>gamble:1</pid></div><div>    </objectFields></div><div>    <objectFields></div><div>      <pid>gamble:10</pid></div><div>    </objectFields></div></div><div>  </resultList></div><div></result></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>