Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - RE: Adding fixed whitespace to XSLT text output? >Thread Next - Re: Adding fixed whitespace to XSLT text output? Re: Adding fixed whitespace to XSLT text output?To: NULL Date: 3/10/2005 9:09:00 AM Thanks! This looks great. I've tried doing a simpler version of this, but the problem I'm running into is that I need to use the variable within a "xsl:for-each" loop, so I can't use the absolute method you use in your xsl:call-template name="str-pad" parameters above. Below is some code showing the trouble I'm running into. Sorry to be dense, but can you help me figure out how to set the variables properly? Thanks so much! <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:variable name="whitespace" select="' '"/> <xsl:template match="/root"> <xsl:variable name="padFoo"> <xsl:call-template name="runStrPad"> <xsl:with-param name="string" select="foo"/> <xsl:with-param name="length" select="16"/> </xsl:call-template> </xsl:variable> <xsl:for-each select="myElement"><xsl:value-of select="$padFoo"/></xsl:for-each> </xsl:template> <xsl:template name="runStrPad"> <xsl:param name="string"/> <xsl:param name="length"/> (runStrPad params: <xsl:value-of select="$string"/>,<xsl:value-of select="$length"/>) <xsl:value-of select="concat($string, substring($whitespace, 1, $length - string-length($string)))"/> </xsl:template> </xsl:stylesheet> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
