have you tried running your java task(s) inside a <parallel> construct?

Or, can you load up more than one Query and then parse the resulting property?

Personally, I would always set fork=”true” in this instance – I do not like the idea of an subtask killing the VM.




From: Tom Cleghorn [mailto:tcleghorn@cambridge.org]
Sent: Thursday, March 08, 2012 1:09 PM
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Saxon Xquery in Ant



I've got an Ant build in which I use the "java" task to pull a couple of values from an XML document and store them in properties for use later in the build.

Currently, the tasks look like this:

<java classname="net.sf.saxon.Query" outputproperty="oc-isbn" fork="true">
    <pathelement location="${basedir}/lib/saxon9.jar"/>
  <arg value="-qs:doc('${xml-meta}')//book[HB_ISBN='${isbn}']/OC_EAN[1] | doc('${xml-meta}')//book[PB_ISBN='${isbn}']/OC_EAN[1]"/>
  <arg value="!method=text"/>

...and this works. However, I have other builds where setting the result of an Xquery to a property would also be useful, but where I have quite a few more properties to set. So, what I'd really like to do is be able to use 'fork="false"', so that I don't have to wait for a new VM to start up for each property, but this does not work. If I do this, I get "Java Result: 2" from Ant, and the properties remain unset.

I played around a bit, and found that Saxon was complaining about Java security permissions, and that led to finding that, if I specifically granted Saxon all permissions, it would run without error, but then end the build prematurely - with some further fiddling, I found that granting Saxon all permissions *except* ExitVM would give me Java Result: 2 again. So it looks as if Saxon really wants to close the VM when it finishes, but with fork=false, this is the VM in which Ant is running - is this the right conclusion? I'm using Ant 1.8.1, Saxon-B 9.1 and Java 1.6, but I've also tried with Ant 1.7.0, 1.7.1 and 1.8.1, and Saxon HE 9.3 and 9.4.

I'm really running up against the boundaries of my understanding of Java here, so I'm honestly unsure if I'm doing something daft, and even if I'm not, whether it's Saxon, Ant, or Java itself that's causing the problem. Can anyone shed any light?

Many thanks!