Package org.apache.axiom.om.xpath
Class AXIOMXPath
java.lang.Object
org.jaxen.BaseXPath
org.apache.axiom.om.xpath.AXIOMXPath
- All Implemented Interfaces:
Serializable
,org.jaxen.XPath
public class AXIOMXPath
extends org.jaxen.BaseXPath
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAXIOMXPath
(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
Modifier and TypeMethodDescriptionvoid
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 givenOMElement
to the namespace context of an XPath expression.Expose the prefix to namespace mapping for this expressionMethods 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
-
Constructor Details
-
AXIOMXPath
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
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. SeeaddNamespaces(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
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 Details
-
addNamespace
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 interfaceorg.jaxen.XPath
- Overrides:
addNamespace
in classorg.jaxen.BaseXPath
- Parameters:
prefix
- a namespace prefixuri
- the URI to which the prefix matches- Throws:
org.jaxen.JaxenException
- if the underlying implementation throws an exception
-
addNamespaces
Add the namespace declarations of a givenOMElement
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
Expose the prefix to namespace mapping for this expression- Returns:
- a Map of namespace prefixes to the URIs
-