Altova Mailing List Archives

Re: Adding fixed whitespace to XSLT text output?

From: "jhouk" <jhouk00@-------.--->
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"

	<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:for-each select="myElement"><xsl:value-of

	<xsl:template name="runStrPad">
		<xsl:param name="string"/>
		<xsl:param name="length"/>
		(runStrPad params: <xsl:value-of select="$string"/>,<xsl:value-of
		<xsl:value-of select="concat($string, substring($whitespace, 1,
$length - string-length($string)))"/>


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 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.