Class AXIOMXPath

  • All Implemented Interfaces:
    Serializable, org.jaxen.XPath

    public class AXIOMXPath
    extends org.jaxen.BaseXPath
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      AXIOMXPath​(String xpathExpr)
      Construct an XPath expression from a given string.
      AXIOMXPath​(OMAttribute attribute)
      Construct an XPath expression from a given attribute.
      AXIOMXPath​(OMElement element, String xpathExpr)
      Construct an XPath expression from a given string and initialize its namespace context based on a given element.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNamespace​(String prefix, String uri)
      This override captures any added namespaces, as the Jaxen BaseXPath class nor NamespaceContext (or SimpleNamespaceContext) exposes thier internal map of the prefixes to the namespaces.
      void addNamespaces​(OMElement element)
      Add the namespace declarations of a given OMElement to the namespace context of an XPath expression.
      Map<String,​String> getNamespaces()
      Expose the prefix to namespace mapping for this expression
      • Methods inherited from class org.jaxen.BaseXPath

        booleanValueOf, createFunctionContext, createNamespaceContext, createVariableContext, debug, evaluate, getContext, getContextSupport, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectNodesForContext, selectSingleNode, selectSingleNodeForContext, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, toString, valueOf
    • Constructor Detail

      • AXIOMXPath

        public AXIOMXPath​(String xpathExpr)
                   throws org.jaxen.JaxenException
        Construct an XPath expression from a given string.
        Parameters:
        xpathExpr - the string representation of the XPath expression.
        Throws:
        org.jaxen.JaxenException - if there is a syntax error while parsing the expression
      • AXIOMXPath

        public AXIOMXPath​(OMElement element,
                          String xpathExpr)
                   throws org.jaxen.JaxenException
        Construct an XPath expression from a given string and initialize its namespace context based on a given element.
        Parameters:
        element - The element that determines the namespace context of the XPath expression. See addNamespaces(OMElement) for more details.
        xpathExpr - the string representation of the XPath expression.
        Throws:
        org.jaxen.JaxenException - if there is a syntax error while parsing the expression or if the namespace context could not be set up
      • AXIOMXPath

        public AXIOMXPath​(OMAttribute attribute)
                   throws org.jaxen.JaxenException
        Construct an XPath expression from a given attribute. The string representation of the expression is taken from the attribute value, while the attribute's owner element is used to determine the namespace context of the expression.
        Parameters:
        attribute - the attribute to construct the expression from
        Throws:
        org.jaxen.JaxenException - if there is a syntax error while parsing the expression or if the namespace context could not be set up
    • Method Detail

      • addNamespace

        public void addNamespace​(String prefix,
                                 String uri)
                          throws org.jaxen.JaxenException
        This override captures any added namespaces, as the Jaxen BaseXPath class nor NamespaceContext (or SimpleNamespaceContext) exposes thier internal map of the prefixes to the namespaces. This method - although is not the ideal solution to the issue, attempts to provide an override to changing the Jaxen code.
        Specified by:
        addNamespace in interface org.jaxen.XPath
        Overrides:
        addNamespace in class org.jaxen.BaseXPath
        Parameters:
        prefix - a namespace prefix
        uri - the URI to which the prefix matches
        Throws:
        org.jaxen.JaxenException - if the underlying implementation throws an exception
      • addNamespaces

        public void addNamespaces​(OMElement element)
                           throws org.jaxen.JaxenException
        Add the namespace declarations of a given OMElement to the namespace context of an XPath expression. Typically this method is used with an XPath expression appearing in an attribute of the given element.

        Note that the default namespace is explicitly excluded and not added to the namespace context. This makes the behaviour of this method consistent with the rules followed in XSL stylesheets. Indeed, the XSLT specification defines the namespace context of an XPath expression as follows:

        the set of namespace declarations are those in scope on the element which has the attribute in which the expression occurs; [...] the default namespace (as declared by xmlns) is not part of this set
        Parameters:
        element - the element to retrieve the namespace context from
        Throws:
        org.jaxen.JaxenException - if an error occurred when adding the namespace declarations
      • getNamespaces

        public Map<String,​String> getNamespaces()
        Expose the prefix to namespace mapping for this expression
        Returns:
        a Map of namespace prefixes to the URIs