Class SynapseXPath
- java.lang.Object
-
- org.jaxen.BaseXPath
-
- org.apache.axiom.om.xpath.AXIOMXPath
-
- org.apache.synapse.config.xml.SynapsePath
-
- org.apache.synapse.util.xpath.SynapseXPath
-
- All Implemented Interfaces:
Serializable
,org.jaxen.XPath
public class SynapseXPath extends SynapsePath
XPath that has been used inside Synapse xpath processing. This has a extension function named
get-property
which is use to retrieve message context properties with the given name from the functionFor example the following function
get-property('prop')
can be evaluatedd using an XPath to retrieve the message context property value with the nameprop
.Apart from that this XPath has a certain set of XPath variables associated with it. They are as follows;
- body
- The SOAP 1.1 or 1.2 body element.
- header
- The SOAP 1.1 or 1.2 header element.
Also there are some XPath prefixes defined in
SynapseXPath
to access various properties using XPath variables, where the variable name represents the particular prefix and the property name as the local part of the variable. Those variables are;- ctx
- Prefix for Synapse MessageContext properties
- axis2
- Prefix for Axis2 MessageContext properties
- trp
- Prefix for the transport headers
This XPath is Thread Safe, and provides a special set of evaluate functions for the
MessageContext
andSOAPEnvelope
as well as a method to retrieve string values of the evaluated XPaths- See Also:
AXIOMXPath
,getContext(Object)
,SynapseXPathFunctionContext
,SynapseXPathVariableContext
, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.synapse.config.xml.SynapsePath
bufferSizeSupport, contentAware, domNamespaceMap, expression, JSON_PATH, X_PATH
-
-
Constructor Summary
Constructors Constructor Description SynapseXPath(String xpathString)
Initializes theSynapseXPath
with the givenxpathString
as the XPathSynapseXPath(String xpathExpr, org.apache.axiom.om.OMElement elem)
Evaluate if the expression is compilable in XPath 2.0 format.SynapseXPath(org.apache.axiom.om.OMAttribute attribute)
Construct an XPath expression from a given attribute.SynapseXPath(org.apache.axiom.om.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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNamespace(org.apache.axiom.om.OMNamespace ns)
Object
evaluate(Object primaryContext, MessageContext secondaryContext)
Specialized form of xpath evaluation function.An xpath evaluate() will be performed using two contexts (ie:-soap-envelope and on Synapse Message Context).String
evaluateDOMXPath(MessageContext synCtx)
protected org.jaxen.Context
getContext(Object obj)
Create aContext
wrapper for the provided object.String
getEvaluator()
boolean
isForceDisableStreamXpath()
static SynapseXPath
parseXPathString(String xPathStr)
void
setEvaluator(String evaluator)
void
setForceDisableStreamXpath(boolean forceDisableStreamXpath)
String
stringValueOf(MessageContext synCtx)
Evaluates the XPath expression against the MessageContext of the current message and returns a String representation of the result-
Methods inherited from class org.apache.synapse.config.xml.SynapsePath
addNamespacesForFallbackProcessing, getExpression, getMessageInputStreamPT, getPathType, handleException, isContentAware, isMessageBiggerThanBuffer, setExpression, setPathType, toString
-
Methods inherited from class org.apache.axiom.om.xpath.AXIOMXPath
addNamespace, addNamespaces, getNamespaces
-
Methods inherited from class org.jaxen.BaseXPath
booleanValueOf, createFunctionContext, createNamespaceContext, createVariableContext, debug, evaluate, getContextSupport, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectNodesForContext, selectSingleNode, selectSingleNodeForContext, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, valueOf
-
-
-
-
Constructor Detail
-
SynapseXPath
public SynapseXPath(String xpathString) throws org.jaxen.JaxenException
Initializes the
SynapseXPath
with the givenxpathString
as the XPath- Parameters:
xpathString
- xpath in its string format- Throws:
org.jaxen.JaxenException
- in case of an initialization failure
-
SynapseXPath
public SynapseXPath(String xpathExpr, org.apache.axiom.om.OMElement elem) throws org.jaxen.JaxenException
Evaluate if the expression is compilable in XPath 2.0 format. This will only be used when its failing to compile in Jaxen- Parameters:
xpathExpr
- XPath expressionelem
- Expression Configurations- Throws:
org.jaxen.JaxenException
- will be thrown if the expression is malformed
-
SynapseXPath
public SynapseXPath(org.apache.axiom.om.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. SeeAXIOMXPath.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
-
SynapseXPath
public SynapseXPath(org.apache.axiom.om.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
-
getEvaluator
public String getEvaluator()
-
setEvaluator
public void setEvaluator(String evaluator)
-
parseXPathString
public static SynapseXPath parseXPathString(String xPathStr) throws org.jaxen.JaxenException
- Throws:
org.jaxen.JaxenException
-
stringValueOf
public String stringValueOf(MessageContext synCtx)
Evaluates the XPath expression against the MessageContext of the current message and returns a String representation of the result
- Specified by:
stringValueOf
in classSynapsePath
- Parameters:
synCtx
- the source message which holds the MessageContext against full context- Returns:
- a String representation of the result of evaluation
-
evaluate
public Object evaluate(Object primaryContext, MessageContext secondaryContext)
Specialized form of xpath evaluation function.An xpath evaluate() will be performed using two contexts (ie:-soap-envelope and on Synapse Message Context). This is useful for evaluating xpath on a nodeset for function contexts (we need both nodeset and synapse ctxts for evaluating function scope expressions)- Parameters:
primaryContext
- a context object ie:- a soap envelopesecondaryContext
- a context object ie:-synapse message ctxt- Returns:
- result
-
addNamespace
public void addNamespace(org.apache.axiom.om.OMNamespace ns) throws org.jaxen.JaxenException
- Throws:
org.jaxen.JaxenException
-
getContext
protected org.jaxen.Context getContext(Object obj)
Create aContext
wrapper for the provided object. This methods implements the following class specific behavior:MessageContext
- The XPath expression is evaluated against the SOAP envelope
and the functions and variables defined by
SynapseXPathFunctionContext
andSynapseXPathVariableContext
are available. SOAPEnvelope
- The variables defined by
SynapseXPathVariableContext
are available.
BaseXPath.getContext(Object)
.Note that the behavior described here also applies to all evaluation methods such as
BaseXPath.evaluate(Object)
orBaseXPath.selectSingleNode(Object)
, given that these methods all usegetContext(Object)
.- Overrides:
getContext
in classorg.jaxen.BaseXPath
- See Also:
SynapseXPathFunctionContext.getFunction(String, String, String)
,SynapseXPathVariableContext.getVariableValue(String, String, String)
-
isForceDisableStreamXpath
public boolean isForceDisableStreamXpath()
-
setForceDisableStreamXpath
public void setForceDisableStreamXpath(boolean forceDisableStreamXpath)
-
evaluateDOMXPath
public String evaluateDOMXPath(MessageContext synCtx) throws XPathExpressionException
- Throws:
XPathExpressionException
-
-