Tuesday, November 15, 2005

XSLT: Padding text output to the right width

I'm writing some XSLT that is supposed to generate a text file. I thought I needed to pad the fields with spaces to get them to the right width, but actually I don't, it is delimited text not fixed width.

Thought I better post this somewhere I can find it again if I need to :)



There's two named templates (read, functions), "spaces" that returns a specified number of spaces (up to 255), and one that uses spaces to do truncation or left-justification. Call it like this:



and the result will be the text "this is too short" with 23 spaces after it (making it 40 chars long).

Comments:
this is perfect, just what I was looking for

matt
 
Thank you, just what i was looking for, too.
 
THANxs!

Just What I was looking for too. Keep Up!
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?