File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes String manipulation in XSLT programming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "String manipulation in XSLT programming" Watch "String manipulation in XSLT programming" New topic
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: 500
    
    3
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: 500
    
    3
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
 
subject: String manipulation in XSLT programming
 
Similar Threads
JDBC -con.string from xml
Question about getter
How You Guys learn Java from A Book
For good programming, In the Hasp Map programming, what value given to Key. As I know I can put any
Searching string in the array