Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Can you force a data length with XSLT? [Thread Next] Re: Can you force a data length with XSLT?To: NULL Date: 9/2/2004 10:38:00 AM Many thanks Oleg - easy when someone explains it to you :-) Darren "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:%233%237XWMkEHA.1712@T...... > Darren Franklin wrote: > > > I cannot seem to find a solution to this and as wondering if anyone with > > more experience than I can see a solution. > > > > Given an example below: > > > > <data>sometext<data> > > > > is it possible to apply a stylesheet, such that the data 'sometext' is > > always longer that a given value, say 10. When it is less than 10 I would > > like spaces to be added to it, i.e. 'sometext ' > > There are lots of methods of doing it. > With EXSLT you can use str:padding() function, in pure XSLT you can do > just the following: > > <!-- Make sure it's enough --> > <xsl:variable name="space" select="' '"/> > > <xsl:value-of select="data"/> > <xsl:if test="string-length(data) < 10"> > <xsl:value-of select="substring($space, 1, 10 - string-length(data))"/> > </xsl:if> > > -- > Oleg Tkachenko [XML MVP] > http://blog.tkachenko.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
