xsl-list
[Top] [All Lists]

Re: [xsl] Need help with XSLT tokenize

2020-08-11 22:30:40
On Tue, Aug 11, 2020 at 5:59 PM Leo Studer 
leo(_dot_)studer(_at_)varioweb(_dot_)ch <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Try something like

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:template match="*Payments*">
        <Orders><xsl:apply-templates/></Orders>
    </xsl:template>
    <xsl:template match="*Payment*">
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="*invoiceDetails*">
        <xsl:for-each select="*tokenize*(., ';')[*position*() lt *last*()]
">
            <xsl:variable name="data" select="."/>
            <Order>
                <OrderNumber><xsl:value-of select="*substring-before*(
*$data*,'#')"/></OrderNumber>
                <OrderAmount><xsl:value-of select="*substring-after*(
*$data*,'#')"/></OrderAmount>
            </Order>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>


I was wanting to write a solution, for this usecase. But above solution
made me feel that, its elegant and correct (based on visual inspection of
the code).

But it seems that, Dimitre has taken the solution to this usecase to new
level.



-- 
Regards,
Mukul Gandhi
--~----------------------------------------------------------------
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>