Xslt WSO2 ESB:XSL转换导致WstxUnexpectedCharException

Xslt WSO2 ESB:XSL转换导致WstxUnexpectedCharException,xslt,wso2,esb,wso2esb,Xslt,Wso2,Esb,Wso2esb,我有一个代理,它需要对来自服务的输出消息进行XSL转换。我已经附加了序列文件和XSL文件(在synaptic configs/local条目中) 如果你能给我一个可能出错的提示,我将不胜感激 以下是序列文件: <?xml version="1.0" encoding="UTF-8"?> <sequence xmlns="http://ws.apache.org/ns/synapse" name="EmpMergeOutSeq1" trace="enable" statistic

我有一个代理,它需要对来自服务的输出消息进行XSL转换。我已经附加了序列文件和XSL文件(在synaptic configs/local条目中)

如果你能给我一个可能出错的提示,我将不胜感激

以下是序列文件:

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="EmpMergeOutSeq1" trace="enable" statistics="enable">
    <log level="full">
        <property name="sequence" value="Final Transform using XSLT - begin"/>
    </log>
    <xslt key="getEmployeeByIdResponseXlt"/>
    <send/>
</sequence>

以下是XSL文件:

<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="getEmployeeByIdResponseXlt">
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ax21="http://domain.hrapp.gunith/xsd" xmlns:ns="http://service.hrapp.gunith" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" version="2.0" exclude-result-prefixes="ns fn">
        <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
        <xsl:template match="/">
            <xsl:apply-templates select="//ns:getEmployeeByIdResponse"/>
        </xsl:template>
        <xsl:template xmlns:ns="http://samples.esb.wso2.org" match="ns:getEmployeeByIdResponse">
            <ns1:getEmployeeByIdResponse xmlns:ns1="http://service.proxy.gunith">
                <ns1:return xmlns:ax22="http://domain.proxy.gunith/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax22:Employee">
                    <ax22:dob>
                        <xsl:value-of select="ns:return/ax21:dob"/>
                    </ax22:dob>
                    <ax22:firstName>
                        <xsl:value-of select="ns:return/ax21:firstName"/>
                    </ax22:firstName>
                    <ax22:id>
                        <xsl:value-of select="ns:return/ax21:id"/>
                    </ax22:id>
                    <ax22:lastName>
                        <xsl:value-of select="ns:return/ax21:lastName"/>
                    </ax22:lastName>
                    <ax22:middleName>
                        <xsl:value-of select="ns:return/ax21:middleName"/>
                    </ax22:middleName>
                </ns1:return>
            </ns1:getEmployeeByIdResponse>
        </xsl:template>
    </xsl:stylesheet>
</localEntry>

以下是日志条目(显示错误和实际传递的消息):

[2012-08-04 11:35:44966]信息-日志中介至:/services/MergedBasicEmployeesProxy.mergedBasicEmployeesProxyHTTPSOAP12端点,WSAction:urn:getEmployeeById,SOAPAction:urn:getEmployeeById,MessageID:urn:uuid:c80fb5a4-41e4-4de4-924d-a18af37b5056,方向:请求,顺序=插入-请求EmpMergeProxy,信封:1
[2012-08-04 11:35:44970]信息-日志中介收件人:/services/MergedBasicEmployeesProxy.MergedBasicEmployeesProxy-TPSOAP12端点,WSAction:urn:getEmployeeById,SOAPAction:urn:getEmployeeById,MessageID:urn:uuid:c80fb5a4-41e4-4de4-924d-a18af37b5056,方向:请求,顺序=插入-请求合并代理,信封:
1.
[2012-08-04 11:35:45504]信息-日志调解人收件人:http://www.w3.org/2005/08/addressing/anonymous,WSAction:,SOAPAction:,MessageID:urn:uuid:ea979246-adbc-494d-bd55-e3ed25171984,方向:响应,序列=使用XSLT的最终转换-开始,信封:1984-03-01Gunith1DevE
[2012-08-04 11:35:45505]信息-日志调解人收件人:http://www.w3.org/2005/08/addressing/anonymous,WSAction:,SOAPAction:,MessageID:urn:uuid:2eb104c0-53c9-4155-8fef-99e7600b7559,方向:响应,序列=使用XSLT的最终转换-开始,信封:1984-03-01Gunith1DevE
[2012-08-04 11:35:45528]错误-XSLTMeditor无法对源XPath使用:Value{name='null',keyValue='getEmployeeByIdResponseXlt'}执行XSLT转换:s11:Body/child::*[position()=1]| s12:Body/child:*[position()=1]

org.apache.axiom.om.OmeException:com.ctc.wstx.exc.WstxUnexpectedCharException:prolog中意外的字符“1”(代码49);预期的“问题出现在xslt脚本上。您可以在eclipse/任何其他xslt处理器中尝试将soap消息作为此xslt脚本的输入xml提供,然后运行。如果脚本正确,您将获得其他输出而不是…

问题在于您的xslt脚本。您可以尝试在eclipse/任何其他xslt处理器中为该xslt脚本提供soap消息作为输入xml并运行。如果脚本正确,您将获得其他输出而不是…

我以前遇到过类似的问题。通常是在XSLT转换期间处理名称空间时。WSO2默认使用xalan.jar作为xml解析器,它被saxon9he.jar替换。以下URL供您参考


谢谢。

我以前也遇到过类似的问题。通常是在XSLT转换期间处理名称空间时。WSO2默认使用xalan.jar作为xml解析器,它被saxon9he.jar替换。以下URL供您参考


谢谢。

谢谢你的帮助!发现了问题。就像你说的,我对XML有问题。非常仔细的检查帮助我找到了它。谢谢你的帮助!发现了问题。就像你说的,我对XML有问题。非常仔细的检查帮助我找到了它。
[2012-08-04 11:35:44,966]  INFO - LogMediator To: /services/MergedBasicEmployeesProxy.MergedBasicEmployeesProxyHttpSoap12Endpoint, WSAction: urn:getEmployeeById, SOAPAction: urn:getEmployeeById, MessageID: urn:uuid:c80fb5a4-41e4-4de4-924d-a18af37b5056, Direction: request, sequence = inSequence - request for EmpMergeProxy, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><p:getEmployeeById xmlns:p="http://service.proxy.gunith"><!--0 to 1 occurrence--><xs:args0 xmlns:xs="http://service.proxy.gunith">1</xs:args0></p:getEmployeeById></soapenv:Body></soapenv:Envelope>
[2012-08-04 11:35:44,970]  INFO - LogMediator To: /services/MergedBasicEmployeesProxy.MergedBasicEmployeesProxyHttpSoap12Endpoint, WSAction: urn:getEmployeeById, SOAPAction: urn:getEmployeeById, MessageID: urn:uuid:c80fb5a4-41e4-4de4-924d-a18af37b5056, Direction: request, sequence = inSequence - request for EmpMergeProxy, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><sam:getEmployeeById xmlns:sam="http://service.hrapp.gunith">
                <sam:args0>1</sam:args0>
            </sam:getEmployeeById></soapenv:Body></soapenv:Envelope>
[2012-08-04 11:35:45,504]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:ea979246-adbc-494d-bd55-e3ed25171984, Direction: response, sequence = Final Transform using XSLT - begin, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:getEmployeeByIdResponse xmlns:ns="http://service.hrapp.gunith"><ns:return xmlns:ax21="http://domain.hrapp.gunith/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:Employee"><ax21:dob>1984-03-01</ax21:dob><ax21:firstName>Gunith</ax21:firstName><ax21:id>1</ax21:id><ax21:lastName>Dev</ax21:lastName><ax21:middleName>E</ax21:middleName></ns:return></ns:getEmployeeByIdResponse></soapenv:Body></soapenv:Envelope>
[2012-08-04 11:35:45,505]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:2eb104c0-53c9-4155-8fef-99e7600b7559, Direction: response, sequence = Final Transform using XSLT - begin, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:getEmployeeByIdResponse xmlns:ns="http://service.hrapp.gunith"><ns:return xmlns:ax21="http://domain.hrapp.gunith/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:Employee"><ax21:dob>1984-03-01</ax21:dob><ax21:firstName>Gunith</ax21:firstName><ax21:id>1</ax21:id><ax21:lastName>Dev</ax21:lastName><ax21:middleName>E</ax21:middleName></ns:return></ns:getEmployeeByIdResponse></soapenv:Body></soapenv:Envelope>
[2012-08-04 11:35:45,528] ERROR - XSLTMediator Unable to perform XSLT transformation using : Value {name ='null', keyValue ='getEmployeeByIdResponseXlt'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1]
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '1' (code 49) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    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:298)
    at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:191)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:229)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:370)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:160)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
    at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:275)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:173)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)