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

Re: Problem with Formatting a string.

Subject: Re: Problem with Formatting a string.
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Tue, 19 Jul 2005 02:25:21 -0700 (PDT)
concat string sh
Hi,
  I think it should be possible to construct a string
variable like this 0000  depending on number of dots,
by writing a recursive named template.

Regards,
Mukul

--- Lakshmi narayana <lchintala@xxxxxxxxxxxx> wrote:

> 
> Hi List,
> 
> I want to format a number based on condition. I
> wrote a template which does
> 1. Input parameter is a string to the template.
> 2. Count number of dots in the string.
> for eg: if input string : 'SH-12.3.4' then number of
> dots = 2
> 3. Format the sequence attribute for that node based
> on the number of dots.
> see the following xslt code.
> <xsl:template name="NewName">
> <xsl:param name="strRep" />
> <xsl:variable name="nrdots"
> select="string-length($strRep) -
> string-length(translate($strRep, '.', ''))" />
> <xsl:choose>
> 	<xsl:when test="$nrdots = 0">
> 		<xsl:value-of
>
select="concat($strRep,concat('.',format-number(./@Sequence,'0')))"/>
> 	</xsl:when>
> 	<xsl:when test="$nrdots = 1">
> 		<xsl:value-of
>
select="concat($strRep,concat('.',format-number(./@Sequence,'00')))"/>
> 	</xsl:when>
> 	<xsl:when test="$nrdots = 2">
> 		<xsl:value-of
>
select="concat($strRep,concat('.',format-number(./@Sequence,'000')))"/>
> 	</xsl:when>
> 	<xsl:when test="$nrdots = 3">
> 		<xsl:value-of
>
select="concat($strRep,concat('.',format-number(./@Sequence,'0000')))"/>
> 	</xsl:when>
> </xsl:choose>
> </xsl:template>
> 
> 4. Suppose there are 4 dots, I have to add one more
> when statement. I have
> to add n number of conditions for n-possible values.
> 5. What I want is, a template which automatically
> formats based on the
> number of dots.
> 
> Can any one send me the standard template for this.
> 
> Thanks
> Ch. Laxmi Narayana Babu
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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.