scriptella.driver.xpath |
XPath Driver for Scriptella.
Allows querying an XML file based on XPath expressions.
General information
Driver class: | scriptella.driver.xpath.Driver |
URL: | XML file URL. URIs are resolved relative to a script file directory. |
Runtime dependencies: | None |
Driver Specific Properties
Name |
Description |
Required |
trim |
Value of true specifies that the leading and trailing
whitespaces in text file lines should be omitted..
| No, the default value is true . |
Query Syntax
XPath driver supports XPath syntax to query text files.
The query is executed on a XML Document and produces a rowset for matched nodes. The attribute
and element values can be referenced from nested scripts/queries. The following example
illustrates querying mechanism:
Example:
XPath: /A selects root element <A>
<A B="1">
<B>2</B>
<C>3</C>
</A>
Available variables for matched element <A>:
The value of variable A represents text content inside XML element <A>,
the value of variable B represents value of B attribute and
the value of variable C represents text content inside element <C>.
Additional notes:
- Currently only Node Set can be selected in XPath expressions, i.e. attributes or elements but not String, Boolean or Number
Script Syntax
<script> elements are not supported by the driver.
Properties substitution
In query elements ${property} or $property syntax is used for properties/variables substition.
Examples
<connection id="in" driver="xpath" url="data.xml"/>
<connection id="out" driver="text" url="report.csv"/>
<query connection-id="in">
/HTML/BODY/TABLE/TR
<script connection-id="out">
$rownum;${td[0]};${td[1]}
</script>
</query>
Extracts rows from tables in data.xml file and produces report.csv.
|
Java Source File Name | Type | Comment |
Driver.java | Class | Represents a driver for querying XML files with XPath expressions. |
XPathConnection.java | Class | Represents a connection to an XML file. |
XPathConnectionPerfTest.java | Class | Tests for
scriptella.driver.xpath.XPathConnection . |
XPathDriverITest.java | Class | Integration test for
scriptella.driver.xpath.Driver XPath driver . |
XPathExpressionCompiler.java | Class | Represents a facade for compiling xpath expressions. |
XPathProviderException.java | Class | Thrown to indicate a problem with XML file querying. |
XPathQueryExecutor.java | Class | Executor for XPath queries. |
XPathQueryExecutorTest.java | Class | Tests for
XPathQueryExecutor . |