xsl-list
[Top] [All Lists]

Re: [xsl] String manipulation in Xslt 1.0

2020-08-27 00:21:40
This does it ;-)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output indent="yes"/>
    
    <xsl:template match="Payments">
        <Payments>
            <xsl:apply-templates/>
        </Payments>
    </xsl:template>
    
    <xsl:template match="Payment">
        <Payment>
            <invoiceDetails>
                <xsl:apply-templates/>
            </invoiceDetails>
        </Payment>
    </xsl:template>
    
    <xsl:template match="invoiceDetails">
        <xsl:param name="details">
            <xsl:if test="ends-with(.,';')"><xsl:value-of select="."/></xsl:if>
            <xsl:if test="not(ends-with(.,';'))"><xsl:value-of 
select="concat(.,';')"/></xsl:if>
        </xsl:param>
        <xsl:variable name="first" select="substring-before($details,';')"/>
        <xsl:variable name="others" select="substring-after($details,';')"/>
           <xsl:value-of select="concat(substring-before($first,'#'),';')"/>
        <xsl:if test="contains($others,'#')">
            <xsl:apply-templates select=".">
                <xsl:with-param name="details" select="$others"/>
            </xsl:apply-templates>
        </xsl:if>
    </xsl:template>
    
</xsl:stylesheet>


Cheers
Leo
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>