[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Field padding in XSLT2

Subject: [xsl] Field padding in XSLT2
From: "Jim Neff" <jneff@xxxxxxxxxxxxxxx>
Date: Fri, 21 Jan 2005 10:35:32 -0500


Here is the code fragment I use to pad a character for an XSL stylesheet
that generates a text document:

<!-- This code copied from
ll -->

	<xsl:template name="pad">
	  <xsl:param name="num" />
	  <xsl:param name="max" />
	  <xsl:param name="char" />
	  <xsl:if test="not($num = $max)">
	      <xsl:value-of select="$char"/>
	    <xsl:call-template name="pad">
	      <xsl:with-param name="num" select="$num + 1"/>
	      <xsl:with-param name="max" select="$max"/>
	      <xsl:with-param name="char" select="$char"/>

The template call to pad for 10 spaces looks like this:

<xsl:call-template name="pad">
      <xsl:with-param name="num"   select="0"/>
      <xsl:with-param name="max"   select="10"/>
      <xsl:with-param name="char"  select="&#x20;"/>

I have the luxury of using XSLT version 2.  Is there a better/faster/easier
way of doing this padding?

Jim Neff

Current Thread