[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Field padding in XSLT2

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

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

<!-- This code copied from
http://www.topxml.com/code/default.asp?p=3&id=v20030419195352&ms=100&l=&sw=A
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"/>
	    </xsl:call-template>
	  </xsl:if>
	</xsl:template>


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;"/>
</xsl:call-template>


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

Thanks,
Jim Neff

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.