简体   繁体   English

WSO2 ESB 4.8.1中的XSLT转换错误

[英]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. 我正在简单代理服务中对传入的Soap / http请求执行XSLT转换。 I am getting the following Error. 我收到以下错误。

Note: i am using WSO2 ESB 4.8.1. 注意:我使用的是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: XSLT文件:

<?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. 问题:我不知道我的XSLT文件有什么问题。 I don't see anything in my prolog. 我的序言中没有看到任何内容。

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 . 这意味着转换输入的根元素不是tns:OrderRequest

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. 请提供您的代理服务配置并输入xml有效负载,以便为您提供更多信息。

如果你在错误中获得“无法使用XSLT结果创​​建OMElement”,则意味着你的模板/命名空间在xslt中与请求消息不匹配。请在这里查看开发者评论

This Error normally expected Payload is not formed to process by XSLT. 此错误通常预期有效负载不会由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. 解决方案:在“本地条目”和“代理服务文件”中更改密钥值后重新启动wso2esb。

Permanent Solution: Write Custom XSLT Mediator to solve this Problem 永久解决方案:编写自定义XSLT介体来解决此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM