net.uworks.andariel
Class XPath

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended bynet.uworks.andariel.XPath

public class XPath
extends org.apache.tools.ant.Task

Task definition for an ANT task that performs a XPath query on a XML file. This task uses the Saxon processor, which should be located in the same classpath as ANT.


 Usage:

   Task declaration in the project:
   
     <taskdef name="xpath" classname="net.uworks.andariel.XPath" />
   

   Task calling syntax:
    
     <xpath file="file" expression="expression" outputproperty="outputproperty" [separator="separator"] [count="true|false"] />
    


   Attributes:
       file            -> The filename of the XML we want to perform the query on.
       outputproperty  -> The name of the property where we want to store the result.
       separator       -> The separator of the results (default is ",")
       count           -> Defines if we want the list of results or if we just want the number of results (defaults to false)


 Crude Example:

     
     <xpath file="build.xml" expression="/project/target/@name" outputproperty="targetNames" />
     

     This example retrieves the names of all the targets from a build.xml file.

 

Since:
Ant 1.5
Version:
$Revision: 1.0 $
Author:
Josep del Rio

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
XPath()
           
 
Method Summary
 void execute()
          Execute this task.
 void setCount(java.lang.String wantCount)
          Set if we only want to count the results of a certain expression.
 void setExpression(java.lang.String expression)
          Set the expression we want to perform over the XML file.
 void setFile(java.lang.String file)
          Set the filename of the XML file we want to check.
 void setOutputproperty(java.lang.String outputproperty)
          Set the name of the property were we want to store the result of the query.
 void setSeparator(java.lang.String separator)
          Set the separator character/characters of each one of the query results.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPath

public XPath()
Method Detail

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Execute this task.

Throws:
org.apache.tools.ant.BuildException - Description of the Exception

setFile

public void setFile(java.lang.String file)
Set the filename of the XML file we want to check.

Parameters:
file - the filename of the XML file.

setExpression

public void setExpression(java.lang.String expression)
Set the expression we want to perform over the XML file.

Parameters:
expression - the XPath expression.

setOutputproperty

public void setOutputproperty(java.lang.String outputproperty)
Set the name of the property were we want to store the result of the query.

Parameters:
outputproperty - the name of the output property.

setSeparator

public void setSeparator(java.lang.String separator)
Set the separator character/characters of each one of the query results.

Parameters:
separator - the results separator.

setCount

public void setCount(java.lang.String wantCount)
Set if we only want to count the results of a certain expression.

Parameters:
wantCount - enables or disables the count mode.