omer khalid
omer khalid

Reputation: 895

XSLT Transformation Error in WSO2 ESB 4.8.1

I am performing a XSLT Transformation on an incoming Soap/http request in simple proxy service. I am getting the following Error.

Note: i am using WSO2 ESB 4.8.1.

Error:

Unable to perform XSLT transformation using : Value {name ='null', keyValue ='gov:/xslt/Interface.xslt'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1] reason : Unable to create an OMElement using XSLT result  {org.apache.synapse.mediators.transform.XSLTMediator}
org.apache.synapse.SynapseException: Unable to create an OMElement using XSLT result 
    at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:302)
    at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:191)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
    at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:411)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,16]
Message: Content is not allowed in prolog.
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
    at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
    at org.apache.synapse.util.jaxp.StreamResultBuilder.getNode(StreamResultBuilder.java:87)
    at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:300)
    ... 12 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,16]
Message: Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:598)
    at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
    at org.apache.axiom.util.stax.dialect.SJSXPStreamReaderWrapper.next(SJSXPStreamReaderWrapper.java:138)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
    ... 17 more

XSLT File:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://com.example/cdm/contract/v1" xmlns:lic="http://com.example/cdm/license/v1" xmlns:org="http://com.example/cdm/organization/v1" xmlns:tns="http://com.example/cdm/order/v1" xmlns:tns1="http://com.example/cdm/customer/v1" xmlns:tns3="http://com.example/cdm/address/v1" xmlns:tns4="http://com.example/cdm/person/v1" xmlns:tns5="http://com.example/cdm/productoffer/v1" xmlns:tns6="http://com.example/cdm/product/v1" xmlns:tns7="http://com.example/cdm/productofferprice/v1" exclude-result-prefixes="tns tns1 tns4 tns3 tns5 tns6 tns7" version="1.0">
  <xsl:template match="/tns:OrderRequest">
    <tns:OrderRequest>
      <tns:Order>
        <tns:OrderHeader>
          <tns:OrderNumber>
            <xsl:value-of select="tns:OrderHeader/tns:OrderNumber" />
          </tns:OrderNumber>
            </tns:OrderHeader>
         </tns:Order>
    </tns:OrderRequest>
  </xsl:template>
</xsl:stylesheet>

Problem: i don't know what is wrong with my XSLT file. I don't see anything in my prolog.

Upvotes: 3

Views: 4468

Answers (4)

Navaneeth
Navaneeth

Reputation: 51

This Error normally expected Payload is not formed to process by XSLT. Once you get this error, after all incoming payload fail to process whether if it is corrected payload.

Solution : Restart wso2esb after Changing Key value in Local entries and Proxy-services File.

Permanent Solution: Write Custom XSLT Mediator to solve this Problem

Upvotes: 0

Jenananthan
Jenananthan

Reputation: 1401

if you are getting "Unable to create an OMElement using XSLT result" in the Error means your template/namespace is not matching in xslt with request message.Please check the developer comment here

Upvotes: 0

Chanaka udaya
Chanaka udaya

Reputation: 5316

Looks like your configuration and the request payload has something to do with this error. Please provide your proxy service configuration and input xml payload to provide you with more insight.

Upvotes: 1

Andreas Veithen
Andreas Veithen

Reputation: 9154

The error indicates that the result of the transformation has non-whitespace text before the root element. The only explanation for this is that your template is never triggered and that only the default templates (which copy text nodes, but not elements) are applied. The would mean that the root element of the input of the transformation is not a tns:OrderRequest.

Upvotes: 3

Related Questions