File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String manipulation in XSLT programming

 
smitha rai
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 650
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi g tsuji,

Working great. Thanks a lot. Yes I am using XSLT 1.0.

Smitha
 
g tsuji
Ranch Hand
Posts: 650
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) &lt; 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic