title: How to use XPATH functions in Mule
body: <p>I have an input SOAP XML as follows :-</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://services.test.com/schema/MainData/V1"&gt;
     &lt;soapenv:Header&gt;
      &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;v1:retrieveDataRequest&gt;
           &lt;v1:Id&gt;662&lt;/v1:Id&gt;
        &lt;/v1:retrieveDataRequest&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>Now my question is simple ...</p>
  
  <p>How can I use XPATH functions like count(),name(),substring() etc in Mule</p>
  
  <p>I want to use XPATH on this SOAP request like the following :-</p>
  
  <pre><code> &lt;logger message="#[xpath('count(//v1:retrieveDataRequest/v1:Id)')]" level="INFO" doc:name="Logger"/&gt;
  </code></pre>
  
  <p>But It is throwing following exception :-</p>
  
  <pre><code>Exception stack is:
  1. No Such Function {http://www.mulesoft.org/schema/mule/core}:count (org.jaxen.UnresolvableException)
    org.jaxen.SimpleFunctionContext:127 (null)
  2. Failed to evaluate XPath expression: "count(//v1:retrieveDataRequest/v1:Id)" (org.mule.api.MuleRuntimeException)
    org.mule.module.xml.expression.AbstractXPathExpressionEvaluator:141 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MuleRuntimeException.html)
  3. org.mule.api.MuleRuntimeException: Failed to evaluate XPath expression: "count(//v1:retrieveDataRequest/v1:Id)" (java.lang.RuntimeException)
    org.mule.module.xml.el.XPathFunction:70 (null)
  4. [Error: org.mule.api.MuleRuntimeException: Failed to evaluate XPath expression: "count(//v1:retrieveDataRequest/v1:Id)"]
  [Near : {... xpath('count(//v1:retrieveData ....}]
               ^
  [Line: 1, Column: 1] (org.mule.mvel2.CompileException)
    org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:437 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/mvel2/CompileException.html)
  5. Execution of the expression "xpath('count(//v1:retrieveDataRequest/v1:Id)')" failed. (org.mule.api.expression.ExpressionRuntimeException)
    org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
  6. Execution of the expression "xpath('count(//v1:retrieveDataRequest/v1:Id)')" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String (org.mule.api.MessagingException)
    org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
  --------------------------------------------------------------------------------
  Root Exception stack trace:
  org.jaxen.UnresolvableException: No Such Function {http://www.mulesoft.org/schema/mule/core}:count
      at org.jaxen.SimpleFunctionContext.getFunction(SimpleFunctionContext.java:127)
      at org.jaxen.ContextSupport.getFunction(ContextSupport.java:242)
      at org.jaxen.Context.getFunction(Context.java:216)
      + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
  </code></pre>
  
  <p><strong>Please note</strong> :- I have already used <strong>Mule namespace-manager</strong> as following :-</p>
  
  <pre><code>&lt;mulexml:namespace-manager includeConfigNamespaces="true"&gt;
      &lt;mulexml:namespace prefix="soapenv" uri="http://schemas.xmlsoap.org/soap/envelope/"/&gt;
      &lt;mulexml:namespace prefix="v1" uri="http://services.test.com/schema/MainData/V1"/&gt;
  &lt;/mulexml:namespace-manager&gt;
  </code></pre>
  
  <p>and I am getting results for the following :-  <code>&lt;logger message="#[xpath('//v1:retrieveDataRequest/v1:Id').text]" level="INFO" doc:name="Logger"/&gt;</code> </p>
  
  <p>Please help</p>