Database Reference
In-Depth Information
collections= "true" outputproperty= "SubCollections" />
<echo> Subcollections to backup: ${SubCollections} </echo>
<foreach list= "${SubCollections}" param= "SubCollection"
target= "BackupCollection" />
</target>
<target name= "BackupCollection" >
<echo> Backup of /db/${SubCollection} </echo>
<property name= "BackupTempDir" value= "backup-${SubCollection}" />
<delete dir= "${BackupTempDir}" />
<mkdir dir= "${BackupTempDir}" />
<xdb:backup uri= "${BaseUri}/${SubCollection}" user= "${Username}"
password= "${Password}" dir= "${BackupTempDir}" />
<zip destfile= "backup-${SubCollection}.zip" basedir= "${BackupTempDir}" />
<delete dir= "${BackupTempDir}" />
</target>
Ant-Contrib's foreach task iterates over a comma-separated list of values and then
calls the BackupCollection task for each one of them.
Run an XQuery from Ant
You can run an XQuery script from within Ant and return the results in a property.
For instance:
<target name= "RunXQuery" description= "Run an XQuery from Ant" >
<xdb:xquery uri= "${BaseUri}" user= "${Username}" password= "${Password}"
outputproperty= "QueryOutput" query= "system:get-exist-home()" />
<echo> Query result: ${QueryOutput} </echo>
</target>
This little task will run the query in the query attribute and, in this case, return the
home directory of eXist. If your query gets more complicated, it will probably be eas‐
ier to store it in a separate file and run it from there. You can accomplish this using
the standard Ant loadfile task:
<loadfile property= "XQueryScript" srcFile= "myscript.xq" />
<xdb:xquery uri= "${BaseUri}" user= "${Username}" password= "${Password}"
outputproperty= "QueryOutput" query= "${XQueryScript}" />
Search WWH ::




Custom Search