Class 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 Detail

      • XPathHandler

        public XPathHandler()
    • 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 expression
        document - Either an instance of ReaderResource, Element or a raw xml String.
        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 expression
        document - Either an instance of ReaderResource, Element or a raw xml String.
        Returns:
        The whole XML snippet, which starts with the tag selected in the xpath expression.
        Throws:
        XPathExpressionException