| Author |
String manipulation in XSLT programming
|
smitha rai
Ranch Hand
Joined: Aug 15, 2001
Posts: 33
|
|
Hi,
I am a new to XSL programming. I have a requirement to add slash at every 4th character in a string. For example, a string value of 'abcdefghijklmn' to be translated to 'abcd/efgh/ijkl/mn'. Appreciate if someone help me out.
Regards,
Smitha
|
 |
g tsuji
Ranch Hand
Joined: Jan 18, 2011
Posts: 375
|
|
I would guess you mean in xslt 1.0, otherwise, it is less tricky in 2.0. This the named template, nothing original just cooking it up, doing that.
I hope you know how to call a named template? This is an illustration calling at a context node with separator "/" and for every 4 character block.
|
 |
smitha rai
Ranch Hand
Joined: Aug 15, 2001
Posts: 33
|
|
Hi g tsuji,
Working great. Thanks a lot. Yes I am using XSLT 1.0.
Smitha
|
 |
g tsuji
Ranch Hand
Joined: Jan 18, 2011
Posts: 375
|
|
Thanks for the feedback. Sounds great you've got the idea.
Just to make a further note on my own post as I read it. On line #6 of the template, it now reads:
line#6-> <xsl:when test="string-length($sin) < number($interval)+1">
I can assure you it has been made such due to the toy formatter (yes, it is for that just a toy). I had scripted it like this:
line#6-> <xsl:when test="string-length($sin) < number($interval)+1">
I have to write &_amp;lt; (without underscore) this time to make it appears properly! and it should be read as such.
ps: I don't see the point of adopting a toy formatter that betrays codes and that the site cannot or not allowed to customize to counter a feature like that. Not more than encouraging members to use code-tag all the time. But coderanch is not alone, so I shouldn't be too harsh on it.
|
 |
 |
|
|
subject: String manipulation in XSLT programming
|
|
|