Package com.bc.ceres.metadata
Class XPathHandler
- java.lang.Object
-
- com.bc.ceres.metadata.XPathHandler
-
public class XPathHandler extends Object
Handles XPath expressions in velocity template files. The expressions parse an input xml file.- Since:
- Ceres 0.13.2
-
-
Constructor Summary
Constructors Constructor Description XPathHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringextractXml(String xpath, Object document)Run a XPath query.Stringrun(String xpath, Object document)Run a XPath query.
-
-
-
Method Detail
-
run
public String run(String xpath, Object document)
Run a XPath query. Call with $xpath.run("XPath expression", $source-XML) in the velocity template. e.g. $xpath.run("//creationDate", $metadata)- Parameters:
xpath- The XPath expressiondocument- Either an instance ofReaderResource,Elementor a raw xmlString.- Returns:
- The demanded information from the XML document.
-
extractXml
public String extractXml(String xpath, Object document) throws XPathExpressionException
Run a XPath query. Call with $xpath.run("XPath expression", $source-XML) in the velocity template. e.g. $xpath.run("//creationDate", $metadata)- Parameters:
xpath- The XPath expressiondocument- Either an instance ofReaderResource,Elementor a raw xmlString.- Returns:
- The whole XML snippet, which starts with the tag selected in the xpath expression.
- Throws:
XPathExpressionException
-
-