Ayodeji
Ayodeji

Reputation: 579

XSLT Transformation not working

I have the following xslt definition

<?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>

to tranform Data below

 <?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>

The expected output should look like this

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

When I run a sample test using Netbeans IDE i get the desired results but running on mule standalone server 3.7.0 throws an exception

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

Also online formatters like this says the xslt is wrong.

Upvotes: 1

Views: 984

Answers (1)

SLWS
SLWS

Reputation: 546

I think this:

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

Should be:

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

You're trying to concat (join) only one thing, the error is saying you need two or more things to join together.

Upvotes: 3

Related Questions