Class JAXPXPathEngine

  • All Implemented Interfaces:
    XPathEngine

    public class JAXPXPathEngine
    extends java.lang.Object
    implements XPathEngine
    Simplified access to JAXP's XPath API.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.xml.xpath.XPath xpath  
    • Constructor Summary

      Constructors 
      Constructor Description
      JAXPXPathEngine()
      Create an XPathEngine that uses JAXP's default XPathFactory under the covers.
      JAXPXPathEngine​(javax.xml.xpath.XPathFactory fac)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String evaluate​(java.lang.String xPath, javax.xml.transform.Source s)
      Evaluates an XPath expression and stringifies the result.
      java.lang.String evaluate​(java.lang.String xPath, org.w3c.dom.Node n)
      Evaluates an XPath expression and stringifies the result.
      java.lang.Iterable<org.w3c.dom.Node> selectNodes​(java.lang.String xPath, javax.xml.transform.Source s)
      Returns a potentially empty collection of Nodes matching an XPath expression.
      java.lang.Iterable<org.w3c.dom.Node> selectNodes​(java.lang.String xPath, org.w3c.dom.Node n)
      Returns a potentially empty collection of Nodes matching an XPath expression.
      void setNamespaceContext​(java.util.Map<java.lang.String,​java.lang.String> prefix2Uri)
      Establish a namespace context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • xpath

        private final javax.xml.xpath.XPath xpath
    • Constructor Detail

      • JAXPXPathEngine

        public JAXPXPathEngine​(javax.xml.xpath.XPathFactory fac)
      • JAXPXPathEngine

        public JAXPXPathEngine()
        Create an XPathEngine that uses JAXP's default XPathFactory under the covers.
    • Method Detail

      • selectNodes

        public java.lang.Iterable<org.w3c.dom.Node> selectNodes​(java.lang.String xPath,
                                                                javax.xml.transform.Source s)
        Returns a potentially empty collection of Nodes matching an XPath expression.
        Specified by:
        selectNodes in interface XPathEngine
      • evaluate

        public java.lang.String evaluate​(java.lang.String xPath,
                                         javax.xml.transform.Source s)
        Evaluates an XPath expression and stringifies the result.
        Specified by:
        evaluate in interface XPathEngine
      • selectNodes

        public java.lang.Iterable<org.w3c.dom.Node> selectNodes​(java.lang.String xPath,
                                                                org.w3c.dom.Node n)
        Returns a potentially empty collection of Nodes matching an XPath expression.
        Specified by:
        selectNodes in interface XPathEngine
      • evaluate

        public java.lang.String evaluate​(java.lang.String xPath,
                                         org.w3c.dom.Node n)
        Evaluates an XPath expression and stringifies the result.
        Specified by:
        evaluate in interface XPathEngine
      • setNamespaceContext

        public void setNamespaceContext​(java.util.Map<java.lang.String,​java.lang.String> prefix2Uri)
        Establish a namespace context.
        Specified by:
        setNamespaceContext in interface XPathEngine
        Parameters:
        prefix2Uri - maps from prefix to namespace URI.