0

I am trying to concatenate a string using a comma as the separator using the following statement:

<xsl:call-template name="textNormal">
                            <xsl:with-param name="text">
                                <xsl:for-each select="/customer/orders/orderNo">
                                    <xsl:value-of select="."/>
                                    ,
                                </xsl:for-each>
                            </xsl:with-param>
                        </xsl:call-template>

The above works but the output comes out as shown below:

213321,123,12312312312,3123123124123432,3142341341432,

How can i change it so that there is no trailing comma at the end of the concatenated string?

Thanks

ziggy
  • 15,677
  • 67
  • 194
  • 287

1 Answers1

1

Based on the answer from https://stackoverflow.com/a/1738918/1606729 and the fact that you want it for XSLT 1.0 it would be:

<xsl:call-template name="textNormal">
    <xsl:with-param name="text">
        <xsl:for-each select="/customer/orders/orderNo">
            <xsl:value-of select="."/>
            <xsl:when test="position() != last()" />,</xsl:when>
        </xsl:for-each>
    </xsl:with-param>
</xsl:call-template>
Community
  • 1
  • 1
koopajah
  • 23,792
  • 9
  • 78
  • 104