title: XQuery transformation with WSO2 ESB
body: <p>I am designing a Proxy Service sequence that includes an XQuery transformation. I have a problem with referencing the registry file containing the transformation.</p>
  
  <p>Here is the sequence:</p>
  
  <pre><code>&lt;sequence name="MySequence" xmlns="http://ws.apache.org/ns/synapse" &gt;
    &lt;xquery key="conf:/wsdl/xqueryRequest.xq"
            target="..."
            xmlns:ns="http://org.apache.synapse/xsd"  &gt;
       &lt;variable xmlns:ns2="http://..." name="var1" expression="..." type="ELEMENT" /&gt;
    &lt;/xquery&gt;
    &lt;send&gt;
       &lt;endpoint&gt;...&lt;/endpoint&gt;
    &lt;/send&gt;
  &lt;/sequence&gt;
  </code></pre>
  
  <p>The file containing the XQuery transformation is uploaded in <pre>/_system/config/wsdl/xqueryRequest.xq</pre></p>
  
  <p>And this is the exception I am getting: </p>
  
  <pre>WARN ERROR_DETAIL : org.apache.synapse.SynapseException: 
  Unable to execute the query at 
  org.apache.synapse.mediators.xquery.XQueryMediator.handleException(XQueryMediator.java:627) at
  org.apache.synapse.mediators.xquery.XQueryMediator.mediate(XQueryMediator.java:130) at
  org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60) at
  ...
  Caused by: java.lang.NullPointerException at
  org.wso2.carbon.mediation.registry.WSO2Registry.lookup(WSO2Registry.java:177) at 
  org.apache.synapse.registry.AbstractRegistry.getResource(AbstractRegistry.java:63) at
  org.apache.synapse.config.SynapseConfiguration.getEntry(SynapseConfiguration.java:693) at
  org.apache.synapse.core.axis2.Axis2MessageContext.getEntry(Axis2MessageContext.java:194) at
  org.apache.synapse.mediators.xquery.XQueryMediator.performQuery(XQueryMediator.java:233) at 
  org.apache.synapse.mediators.xquery.XQueryMediator.mediate(XQueryMediator.java:123) 
  ... 11 more 
  </pre>
  
  <p>The exception shows a NullPointer at WSO2Registry.lookup so I assume that the problem is in finding the XQuery file in the registry, this part: </p>
  
  <p><pre>key="conf:/wsdl/xqueryRequest.xq"</pre></p>
  
  <p>The documentation shows two code snippets(<a href="http://wso2.org/project/esb/java/4.0.2/docs/samples/advanced_mediation_samples.html#Sample390" rel="nofollow">390</a> and <a href="http://wso2.org/project/esb/java/4.0.2/docs/samples/advanced_mediation_samples.html#Sample391" rel="nofollow">391</a>) with XQuery transformation but non of them explains howto reference the XQuery file. </p>
  
  <p><strong>Question</strong>: What should be the correct value for the key parameter? Do I need to use the "Local Entry" feature? If yes, then should I define the value as "Inline XML Entry" or "Inline Text"?</p>
  
  <p><strong>UPDATE 03/23/12:</strong></p>
  
  <p><strong>Question 2</strong>: Perhaps a simpler question: Where should I copy/upload the xqueryRequest.xq file when I set Xquery mediator's key field to <strong>key="xqueryRequest.xq"</strong>?</p>