XSLT转换无法正常工作

时间:2017-03-31 18:19:09

标签: java xml xslt mule

我有以下xslt定义

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:fo="http://www.w3.org/1999/XSL/Format" >
    <xsl:output method="text" omit-xml-declaration="yes" indent="yes"/>
    <xsl:template match="/">
        <xsl:value-of select="concat(//RedemptionFileName)"/>
            <xsl:for-each select="//ErrorMessageList/ErrorMessage">
                <xsl:value-of select="concat(',',OrderNumber,',',OrderLineItemNumber,',',ErrorCode)"/>
            </xsl:for-each> 
    </xsl:template>
</xsl:stylesheet>

转换以下数据

 <?xml version="1.0" encoding="utf-8"?>
<ReceiptDetails xmlns="http://centivesolutions.com/AAA_Receipt.xsd">
    <schemaVersion>10.4</schemaVersion>
    <RedemptionFileName>IncommBIFCFS_Order_20140319110741741.xml</RedemptionFileName>
    <ErrorMessageList>
        <ErrorMessage>
            <OrderNumber>1615296</OrderNumber>
            <OrderLineItemNumber>1910642</OrderLineItemNumber>
            <ErrorCode>SNF</ErrorCode>
            <ErrorDesc>street not found in city (finance number)</ErrorDesc>
        </ErrorMessage>
        <ErrorMessage>
            <OrderNumber>1615297</OrderNumber>
            <OrderLineItemNumber>1910643</OrderLineItemNumber>
            <ErrorCode>SNF</ErrorCode>
            <ErrorDesc>street not found in city (finance number)</ErrorDesc>
        </ErrorMessage>
        <ErrorMessage>
            <OrderNumber>1615298</OrderNumber>
            <OrderLineItemNumber>1910644</OrderLineItemNumber>
            <ErrorCode>BNC</ErrorCode>
            <ErrorDesc>PO Box not found in city (finance number)</ErrorDesc>
        </ErrorMessage>
        <ErrorMessage>
            <OrderNumber>1615299</OrderNumber>
            <OrderLineItemNumber>1910645</OrderLineItemNumber>
            <ErrorCode>ANS</ErrorCode>
            <ErrorDesc>address not on street</ErrorDesc>
        </ErrorMessage>
    </ErrorMessageList>
</ReceiptDetails>

预期输出应如下所示

IncommBIFCFS_Order_20140319110741741.xml,1615296,1910642,SNF,1615297,1910643,SNF,1615298,1910644,BNC,1615299,1910645,ANS

当我使用Netbeans IDE运行示例测试时,我得到了预期的结果,但在mule独立服务器3.7.0上运行会引发异常

org.apache.xpath.functions.FuncConcat only allows >1 arguments

同样在线格式化程序如this表示xslt错误。

1 个答案:

答案 0 :(得分:3)

我想这个:

<xsl:value-of select="concat(//RedemptionFileName)"/>

应该是:

<xsl:value-of select="//RedemptionFileName" />

你只是尝试连接(加入)一件事,错误是说你需要两件或两件以上的东西才能加入。