<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Hi Danny,</div>
<div><br>
</div>
<div>Jumping in late on this thread, but wanted to remark that you might not need to go through al this if you switched from doing GETís to this endpoint to using POST or PUT..</div>
<div><br>
</div>
<div>Cheers</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Danny Sinang &lt;<a href="mailto:d.sinang@gmail.com">d.sinang@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@developer.marklogic.com">general@developer.marklogic.com</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Thursday, March 12, 2015 at 4:03 AM<br>
<span style="font-weight:bold">To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@developer.marklogic.com">general@developer.marklogic.com</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [MarkLogic Dev General] REST API call results in XDMP-UPDATEFUNCTIONFROMQUERY<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">Thanks Joe.
<div><br>
</div>
<div>I decided to not use xdmp:spawn anymore.&nbsp;</div>
<div><br>
</div>
<div>Here's the working code :</div>
<div><br>
</div>
<div>==========================================================</div>
<div>
<p class=""><span class=""><b>xquery version </b></span><span class="">&quot;1.0-ml&quot;</span>;<br>
<br>
<span class=""><b>module namespace </b></span><span class=""><b>local</b></span> <span class="">
=</span> <span class="">&quot;<a href="http://marklogic.com/rest-api/resource/resize">http://marklogic.com/rest-api/resource/resize</a>&quot;</span>;<br>
<br>
<span class=""><b>declare namespace </b></span><span class=""><b>rapi</b></span> <span class="">
=</span> <span class="">&quot;<a href="http://marklogic.com/rest-api">http://marklogic.com/rest-api</a>&quot;</span>;<br>
<br>
<span class=""><b>declare</b></span> <span class="">%rapi:transaction-mode(&quot;update&quot;)</span><span class=""><b>function</b></span>
<span class=""><i>local:get</i></span>(<span class=""><b>$context</b></span><span class=""><b>as
</b></span><span class=""><b>map:map</b></span>, <span class=""><b>$params</b></span>&nbsp;
<span class=""><b>as </b></span><span class=""><b>map:map</b></span>) <span class="">
<b>as </b></span><span class=""><i>document-node</i></span>()* { &nbsp; &nbsp; <br>
<span class=""></span><span class=""><b>let </b></span><span class=""><b>$image_server_root</b></span>&nbsp; :=
<span class="">&quot;<a href="http://solrdev1.mycompany.com:7000/resize_image">http://solrdev1.mycompany.com:7000/resize_image</a>&quot;</span>&nbsp; &nbsp;
<br>
<span class=""></span><span class=""><b>let</b></span> <span class=""><b>$uri</b></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :=
<span class=""><i>map:get</i></span>(<span class=""><b>$params</b></span>,<span class="">&quot;uri&quot;</span>)&nbsp; &nbsp;
<br>
<span class=""></span><span class=""><b>let</b></span> <span class=""><b>$width</b></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :=
<span class=""><i>map:get</i></span>(<span class=""><b>$params</b></span>,<span class="">&quot;width&quot;</span>)&nbsp; &nbsp;
<br>
<span class=""></span><span class=""><b>let</b></span> <span class=""><b>$height</b></span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :=
<span class=""><i>map:get</i></span>(<span class=""><b>$params</b></span>,<span class="">&quot;height&quot;</span>)&nbsp; &nbsp;
<br>
<span class=""></span><span class=""><b>let</b></span> <span class=""><b>$resized_uri</b></span>&nbsp; &nbsp; &nbsp; &nbsp; :=
<span class=""><i>fn:concat</i></span>(<span class=""><i>fn:substring-before</i></span>(<span class=""><b>$uri</b></span>,<span class="">&quot;.jpg&quot;</span>),<span class="">&quot;_&quot;</span>,<span class=""><b>$width</b></span>,<span class="">&quot;_&quot;</span>,<span class=""><b>$height</b></span>,<span class="">&quot;.jpg&quot;</span>)&nbsp;
 &nbsp; &nbsp; &nbsp; <br>
<span class=""></span><span class=""><b>let</b></span> <span class=""><b>$resized_image</b></span>&nbsp; &nbsp; &nbsp; :=&nbsp;
<br>
<span class=""></span><span class=""></span><span class=""></span><span class=""><b>if</b></span> (<span class=""><i>xdmp:uri-is-file</i></span>(<span class=""><b>$resized_uri</b></span>))
<span class=""><b>then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </b></span><br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><i>fn:doc</i></span>(<span class=""><b>$resized_uri</b></span>)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span class=""></span><span class=""></span><span class=""></span><span class=""><b>else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</b></span><br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><b>let
</b></span><span class=""><b>$image</b></span>&nbsp; &nbsp; &nbsp; := <span class=""><i>fn:doc</i></span>(<span class=""><b>$uri</b></span>)/<span class=""><i>node</i></span>()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><b>let</b></span><span class=""><b>$image_name</b></span> :=
<span class=""><i>fn:tokenize</i></span>(<span class=""><b>$uri</b></span>,<span class="">&quot;/&quot;</span>)[<span class=""><i>last</i></span>()]&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><b>let</b></span><span class=""><b>$temp_image</b></span> :=
<span class=""><i>xdmp:http-put</i></span>(<span class=""><i>fn:concat</i></span>(<span class=""><b>$image_server_root</b></span>,<span class="">&quot;/&quot;</span>,<span class=""><b>$width</b></span>,<span class="">&quot;/&quot;</span>,<span class=""><b>$height</b></span>,<span class="">&quot;/&quot;</span>,<span class=""><b>$image_name</b></span>,<span class="">&quot;?resized_uri=&quot;</span>,<span class=""><b>$resized_uri</b></span>),
 (), <span class=""><b>$image</b></span>)[<span class="">2</span>]<br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><b>let</b></span><span class=""><b>$_</b></span> :=
<span class=""><i>xdmp:document-insert</i></span>(<span class="">&quot;/2014/11/20/danny.jpg&quot;</span>,
<span class=""><b>$temp_image</b></span>, <span class=""><i>xdmp:default-permissions</i></span>())
<br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><b>return
</b></span><br>
<span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""><b>$temp_image</b></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span class=""></span><span class=""><b>let</b></span> <span class=""><b>$mime_type</b></span> :=
<span class=""><i>map:put</i></span>(<span class=""><b>$context</b></span>,<span class="">&quot;output-types&quot;</span>,<span class="">&quot;image/jpeg&quot;</span>)&nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span class=""></span><span class=""><b>return document</b></span>{<span class=""><b>$resized_image</b></span>}<br>
};</p>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar 11, 2015 at 8:57 PM, Joe Bryan <span dir="ltr">
&lt;<a href="mailto:Joe.Bryan@marklogic.com" target="_blank">Joe.Bryan@marklogic.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>Hi Danny,</div>
<div><br>
</div>
<div>You don't have to make the entire transaction a query to spawn an update; you can explicitly set the transaction-mode in the xdmp:spawn-function expression. (note: you will have to explicitly commit the update transaction)</div>
<div><br>
</div>
<div>Ex:</div>
<div><br>
</div>
<div>
<div>xdmp:spawn-function(function() {</div>
<div>&nbsp; &nbsp; xdmp:document-insert(&quot;/2014/11/20/danny.jpg&quot;, $temp_image, xdmp:default-permissions()),</div>
<div>&nbsp; &nbsp; xdmp:commit()</div>
<div>&nbsp; },</div>
<div>&nbsp; &lt;options xmlns=&quot;xdmp:eval&quot;&gt;</div>
<div>&nbsp; &nbsp; &lt;transaction-mode&gt;update&lt;/transaction-mode&gt;</div>
<div>&nbsp; &lt;/options&gt;)</div>
</div>
<div><br>
</div>
<div>Thanks.</div>
<div><br>
</div>
<div>-jb</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>Danny Sinang &lt;<a href="mailto:d.sinang@gmail.com" target="_blank">d.sinang@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@developer.marklogic.com" target="_blank">general@developer.marklogic.com</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Wednesday, March 11, 2015 at 2:34 PM<br>
<span style="font-weight:bold">To: </span>general &lt;<a href="mailto:General@developer.marklogic.com" target="_blank">General@developer.marklogic.com</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [MarkLogic Dev General] REST API call results in XDMP-UPDATEFUNCTIONFROMQUERY<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">I think it's working now.
<div><br>
</div>
<div>Just added this line :</div>
<p><span><b>declare namespace </b></span><span><b>rapi</b></span><span></span><span>=</span><span></span>&quot;<a href="http://marklogic.com/rest-api" target="_blank">http://marklogic.com/rest-api</a>&quot;<span>;</span></p>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar 11, 2015 at 3:27 PM, Danny Sinang <span dir="ltr">
&lt;<a href="mailto:d.sinang@gmail.com" target="_blank">d.sinang@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I tried prefixing my function declaration like this :
<div><br>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<p><span><b>declare</b></span><span> </span>%rapi:transaction-mode(&quot;update&quot;)</p>
</div>
</blockquote>
<div>
<div>as suggested in&nbsp;<a href="http://docs.marklogic.com/guide/rest-dev/extensions#id_17130" target="_blank">http://docs.marklogic.com/guide/rest-dev/extensions#id_17130</a> .</div>
<div><br>
</div>
<div>But I'm now getting this error :</div>
<div><br>
</div>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px">XDMP-UNBPRFX: (err:XPST0081) Prefix rapi has no namespace binding.</span></div>
</div>
</blockquote>
<div>
<div>
<div><br>
</div>
</div>
</div>
<div>Regards,</div>
<div>Danny</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar 11, 2015 at 3:00 PM, Danny Sinang <span dir="ltr">
&lt;<a href="mailto:d.sinang@gmail.com" target="_blank">d.sinang@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>Hello,</div>
<div><br>
</div>
<div>Whenever I make call to&nbsp;</div>
<div><br>
</div>
<div><a href="http://marklogic.mycompany.com:9042/v1/resources/resize?rs:width=300&amp;rs:height=300&amp;rs:uri=/2014/11/20/IC20141120.jpg" target="_blank">http://marklogic.mycompany.com:9042/v1/resources/resize?rs:width=300&amp;rs:height=300&amp;rs:uri=/2014/11/20/IC20141120.jpg</a><br>
</div>
<div><br>
</div>
<div>I get this error message :</div>
<div><br>
</div>
<div><span style="color: rgb(95, 175, 239); display: inline-block; padding: 0px 3px; white-space: nowrap; border: 1px solid transparent; border-top-left-radius: 0.8em; border-top-right-radius: 0.8em; border-bottom-right-radius: 0.8em; border-bottom-left-radius: 0.8em; font-family: Consolas, 'DejaVu Sans Mono', monospace; font-size: 11px;">&lt;<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:error</span>&nbsp;<span style="color:rgb(79,159,207)"><span>xmlns:rapi</span>=&quot;<span style="color:rgb(212,73,80)"><a href="http://marklogic.com/rest-api" style="color:rgb(23,50,180)" target="_blank">http://marklogic.com/rest-api</a></span>&quot;</span>&gt;</span><span style="color:rgb(0,0,0);font-family:Consolas,'DejaVu Sans Mono',monospace;font-size:11px"><span style="padding:0.25em 0px 0.2em 15px;display:block"><span style="color:rgb(95,175,239);display:inline;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:status-code</span>&gt;</span><span>500</span><span style="color:rgb(95,175,239);display:inline;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;/<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:status-code</span>&gt;</span></span><span style="padding:0.25em 0px 0.2em 15px;display:block"><span style="color:rgb(95,175,239);display:inline;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:status</span>&gt;</span><span>INTERNAL
 ERROR</span><span style="color:rgb(95,175,239);display:inline;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;/<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:status</span>&gt;</span></span><span style="padding:0.25em 0px 0.2em 15px;display:block"><span style="color:rgb(95,175,239);display:inline;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:message-code</span>&gt;</span><span>XDMP-UPDATEFUNCTIONFROMQUERY</span><span style="color:rgb(95,175,239);display:inline;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;/<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:message-code</span>&gt;</span></span><span style="padding:0.25em 0px 0.2em 15px;display:block"><span style="display:inline-block;width:10px;min-height:1em;margin-top:0.15em"></span><span style="color:rgb(95,175,239);display:inline-block;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:message</span>&gt;</span><span><span style="padding-left:20px;display:block">XDMP-UPDATEFUNCTIONFROMQUERY:
 Q{<a href="http://marklogic.com/rest-api/resource/resize" style="color:rgb(23,50,180)" target="_blank">http://marklogic.com/rest-api/resource/resize</a>}get#2($context, $service-params) -- Cannot apply an update function from a query. See the MarkLogic server
 error log for further detail.</span></span><span style="color:rgb(95,175,239);display:inline-block;padding:0px 3px;white-space:nowrap;border:1px solid transparent;border-radius:0.8em">&lt;/<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:message</span>&gt;</span></span></span><span style="color: rgb(95, 175, 239); display: inline-block; padding: 0px 3px; white-space: nowrap; border: 1px solid transparent; border-top-left-radius: 0.8em; border-top-right-radius: 0.8em; border-bottom-right-radius: 0.8em; border-bottom-left-radius: 0.8em; font-family: Consolas, 'DejaVu Sans Mono', monospace; font-size: 11px;">&lt;/<span style="color:rgb(47,111,159);background-color:rgb(244,250,255)">rapi:error</span>&gt;</span><br>
</div>
<div><br>
</div>
<div>I know this happens because of the xdmp:document-insert() call inside the code for that API call.</div>
<div><br>
</div>
<div>My question is, is there a workaround for this ?&nbsp;</div>
<div><br>
</div>
<div>I already tried wrapping the document-insert call with xdmp:spawn-function, but that didn't work either.</div>
<div><br>
</div>
<div>Below is the code.</div>
<div><br>
</div>
<div>Regards,<br>
Danny</div>
<div><br>
</div>
<div>=======================================================================================</div>
<div>
<p><span><b>xquery version </b></span><span>&quot;1.0-ml&quot;</span>;<br>
<br>
<span><b>module namespace </b></span><span><b>local</b></span> <span>=</span> <span>
&quot;<a href="http://marklogic.com/rest-api/resource/resize" target="_blank">http://marklogic.com/rest-api/resource/resize</a>&quot;</span>;<br>
<br>
<span><b>declare option </b></span><span><b>xdmp:update</b></span> <span>&quot;true&quot;</span>;<br>
<br>
<span><b>declare function </b></span><span><i>local:get</i></span>(<span><b>$context</b></span><span><b>as
</b></span><span><b>map:map</b></span>, <span><b>$params</b></span>&nbsp; <span><b>as </b>
</span><span><b>map:map</b></span>) <span><b>as </b></span><span><i>document-node</i></span>()* { &nbsp; &nbsp;
<br>
<span></span><span><b>let </b></span><span><b>$image_server_root</b></span>&nbsp; := <span>
&quot;<a href="http://solrdev1.mycompany.com:7000/resize_image" target="_blank">http://solrdev1.mycompany.com:7000/resize_image</a>&quot;</span>&nbsp; &nbsp;
<br>
<span></span><span><b>let</b></span> <span><b>$uri</b></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := <span>
<i>map:get</i></span>(<span><b>$params</b></span>,<span>&quot;uri&quot;</span>)&nbsp; &nbsp; <br>
<span></span><span><b>let</b></span> <span><b>$width</b></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := <span>
<i>map:get</i></span>(<span><b>$params</b></span>,<span>&quot;width&quot;</span>)&nbsp; &nbsp; <br>
<span></span><span><b>let</b></span> <span><b>$height</b></span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; := <span>
<i>map:get</i></span>(<span><b>$params</b></span>,<span>&quot;height&quot;</span>)&nbsp; &nbsp; <br>
<span></span><span><b>let</b></span> <span><b>$resized_uri</b></span>&nbsp; &nbsp; &nbsp; &nbsp; := <span>
<i>fn:concat</i></span>(<span><i>fn:substring-before</i></span>(<span><b>$uri</b></span>,<span>&quot;.jpg&quot;</span>),<span>&quot;_&quot;</span>,<span><b>$width</b></span>,<span>&quot;_&quot;</span>,<span><b>$height</b></span>,<span>&quot;.jpg&quot;</span>)&nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span></span><span><b>let</b></span> <span><b>$resized_image</b></span>&nbsp; &nbsp; &nbsp; :=&nbsp; <br>
<span></span><span></span><span></span><span><b>if</b></span> (<span><i>xdmp:uri-is-file</i></span>(<span><b>$resized_uri</b></span>))
<span><b>then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </b></span><br>
<span></span><span></span><span></span><span></span><span></span><span><i>fn:doc</i></span>(<span><b>$resized_uri</b></span>)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span></span><span></span><span></span><span><b>else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</b></span><br>
<span></span><span></span><span></span><span></span><span></span><span><b>let </b>
</span><span><b>$image</b></span>&nbsp; &nbsp; &nbsp; := <span><i>fn:doc</i></span>(<span><b>$uri</b></span>)/<span><i>node</i></span>()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span></span><span></span><span></span><span></span><span></span><span><b>let</b></span><span><b>$image_name</b></span> :=
<span><i>fn:tokenize</i></span>(<span><b>$uri</b></span>,<span>&quot;/&quot;</span>)[<span><i>last</i></span>()]&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span></span><span></span><span></span><span></span><span></span><span><b>let</b></span><span><b>$temp_image</b></span> :=
<span><i>xdmp:http-put</i></span>(<span><i>fn:concat</i></span>(<span><b>$image_server_root</b></span>,<span>&quot;/&quot;</span>,<span><b>$width</b></span>,<span>&quot;/&quot;</span>,<span><b>$height</b></span>,<span>&quot;/&quot;</span>,<span><b>$image_name</b></span>,<span>&quot;?resized_uri=&quot;</span>,<span><b>$resized_uri</b></span>),
 (), <span><b>$image</b></span>)[<span>2</span>]<br>
<span></span><span></span><span></span><span></span><span></span><span><b>let</b></span><span><b>$_</b></span> :=
<span><i>xdmp:spawn-function</i></span>(<span><b>function</b></span>() { <span><i>xdmp:document-insert</i></span>(<span>&quot;/2014/11/20/danny.jpg&quot;</span>,
<span><b>$temp_image</b></span>, <span><i>xdmp:default-permissions</i></span>()) })&nbsp;
<br>
<span></span><span></span><span></span><span></span><span></span><span><b>return </b>
</span><br>
<span></span><span></span><span></span><span></span><span></span><span></span><span><b>$temp_image</b></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span></span><span><b>let</b></span> <span><b>$mime_type</b></span> := <span><i>map:put</i></span>(<span><b>$context</b></span>,<span>&quot;output-types&quot;</span>,<span>&quot;image/jpeg&quot;</span>)&nbsp; &nbsp; &nbsp; &nbsp;
<br>
<span></span><span><b>return document</b></span>{<span><b>$resized_image</b></span>}<br>
};</p>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span></div>
<br>
_______________________________________________<br>
General mailing list<br>
<a href="mailto:General@developer.marklogic.com">General@developer.marklogic.com</a><br>
<a href="http://developer.marklogic.com/mailman/listinfo/general" target="_blank">http://developer.marklogic.com/mailman/listinfo/general</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span>
</body>
</html>