[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Please look at my mini-template

Subject: Please look at my mini-template
From: Dmitri Snytkine <d.snytkine@xxxxxxxxx>
Date: Fri, 15 May 2009 19:41:00 -0400
 Please look at my mini-template
Hello!

I needed this functionality:
Given the input of a HEX number (example 2A32BF42)
I needed to split the string in such a way that a '/' is inserted
after every 2 characters except that
the '/' should NOT be added at the end of string.

So 2A32BF42 has to become 2A/32/BF/42

This had to be done in XSLT 1 because its for browser-based transformations.

I wrote a template for this and want to hear the opinion of the
experts. I just started learning XSLT about a week ago.
So what do you think?

Here it is:

<xsl:template name="hex2path">
        <xsl:param name="left" select="''"/>
        <xsl:param name="right"/>
        <xsl:choose>
            <xsl:when test="(string-length($right) > 2)">

                <xsl:call-template name="hex2path">
                    <xsl:with-param name="left">
                        <xsl:value-of select="concat($left,
concat(substring($right, 1, 2), '/'))"/>
                    </xsl:with-param>
					<xsl:with-param name="right">
						<xsl:value-of select="substring($right, 3)"/>
						</xsl:with-param>
                </xsl:call-template>

            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="concat($left, $right)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.