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 String
extractXml(String xpath, Object document)
Run a XPath query.String
run(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
,Element
or 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
,Element
or a raw xmlString
.- Returns:
- The whole XML snippet, which starts with the tag selected in the xpath expression.
- Throws:
XPathExpressionException
-
-