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

Re: Converting XML data

Subject: Re: Converting XML data
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 10 Aug 2004 12:34:04 +0100
xslt recursive character by character
Hi Narasingarao,

> I need to format data from the XML in my XSL using functions.
>
> example :   Input data from XML is HELLO , i want the output as | H  |   E
> |  L  |  L  | O  |

In XSLT 1.0, you need a recursive function to step through the string
"HELLO" character-by-character, on each recursion outputting "| " plus
the character (if there is one), and stopping recursion if there's no
string left. Here's an example:

<xsl:template name="separate-characters">
  <xsl:param name="string" select="'HELLO'" />
  <xsl:text>| </xsl:text>
  <xsl:if test="$string">
    <xsl:value-of select="concat(substring($string, 1, 1), ' ')" />
    <xsl:call-template name="separate-characters">
      <xsl:with-param name="string" select="substring($string, 2)" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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.