Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Can you force a data length with XSLT?

From: "Oleg Tkachenko [MVP]" <oleg@--!----!---------------.--->
To: NULL
Date: 9/2/2004 11:17:00 AM
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) &lt; 10">
   <xsl:value-of select="substring($space, 1, 10 - string-length(data))"/>
</xsl:if>

-- 
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent