I'm surprised it worked in 8.7 - I thought this optimization had been in the product much longer than that.

If variables aren't used, then they aren't evaluated. You can't declare a variable just in order to achieve side-effects. Even if the variables are evaluated, you can't rely on the order in which they are evaluated.

Basically, to fool Saxon into executing non-deterministic functions like these, you have to pretend to make use of the result (in effect, you're simulating a monad). If the external methods return void, then the delivered result will be an empty sequence, and if you include this empty sequence in your query result, this will force Saxon to evaluate the function and thus trigger the side-effects. For example, if you called your three $doc variables $doc1, $doc2, and $doc3, you could simply do

return <response>{$doc1, $doc2, $doc3/response/*}</response>

Note that even this might not be enough to ensure that the variables are evaluated in the right order. To achieve that, you need to make the evaluation of a variable functionally dependent on the results of actions that you want to precede it.

Michael Kay
Saxonica

On 23/02/2013 20:08, Boysen, Pete [ITACD] wrote:

The following xquery worked in 8.7 but not in 9.1.0.8.  All but the copyResources extension is ignored.

 

xquery version "1.0";

declare namespace QueryUpdate = "java:edu.iastate.its.thinkspace.core.xquery.QueryUpdate";

declare namespace SpaceFileService = "java:edu.iastate.its.thinkspace.core.filesystem.SpaceFileService";

 

declare variable $spaceFileService external;

declare variable $state external;

declare variable $_operationType external;

declare variable $user external;

declare variable $upd external;

declare variable $args external;

 

let $status := 0

let $root := concat('/space/',$args/args/pid/.,'/')

let $profile :=

<profile _n="2" background="white" layout="60%,40%" id="{$args/args/pid/.}" help="true" theme="EnterpriseBlue">

      <apps>

      <app column="0" id="addapp" minimized="false" name="Apps" type="addapp" url=""/>

      <app column="0" id="profileapp" minimized="false" name="Profile" type="profileapp"

           url=""/>

      <app column="1" id="spacesapp" minimized="false" name="my Spaces" type="spacesapp"

           url=""/>

      <app column="1" id="portfolioapp" minimized="false" name="My Portfolios"

           type="portfolioapp"

           url=""/>

      <app column="2" id="libraryapp" minimized="false" name="My Docs" type="libraryapp"

           url=""/>

      </apps>

</profile>

let $dirs :=  ('lib/','logs/','lib/archives/','lib/templates/','lib/public/')

let $doc := SpaceFileService:makeDirectories($spaceFileService,$state,$root,$dirs)

let $doc := QueryUpdate:createDoc($upd,concat($root,'profile.xml'),$profile)

let $files := '/gwt/ckeditor/styles.js,/gwt/ckeditor/templates.js'

let $doc := SpaceFileService:copyResources($spaceFileService,$state,$files,concat($root,'lib/templates/'))

return

      <response>

            {$doc/response/*}

      </response>

 

 

Pete Boysen(pboysen@iastate.edu)

Information Technology Services

209 Durham

(515)294-6663

 



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help