This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: creating a string of repeated charactors


Thanks Jim,

for the link to
http://www.exslt.org/str/functions/padding/str.padding.template.xsl

It seems that repeating charactors isn't a part of XSLT at this stage - not
as a function

The EXSLT function <xsl:value-of select="str:padding(10, '*')" /> function
is the sort of thing I hoped might exist in *standard* XSLT.

Since there isn't I'll use the template that you pointed me to instead.
(Thanks for saving me from writing it! :) )

I was hoping that there might me a less verbose way of doing what really is
quite a simple task.

Tim

For others interested, but don't feel like checking the links, the template
is...

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:str="http://exslt.org/strings"; extension-element-prefixes="str">
  <xsl:template name="str:padding">
  <xsl:param name="length" select="0" />
  <xsl:param name="chars" select="' '" />
    <xsl:choose>
      <xsl:when test="not($length)" />
      <xsl:when test="string-length($chars) >= $length">
        <xsl:value-of select="substring($chars, 1, $length)" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="str:padding">
          <xsl:with-param name="length" select="$length" />
          <xsl:with-param name="chars" select="concat($chars, $chars,
$chars)" />
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

-----Original Message-----
From: cutlass

there are many ways of doing this, try looking at the exslt.org link below

http://www.exslt.org/str/functions/padding/index.html

here is the link to the xslt template u may use

http://www.exslt.org/str/functions/padding/str.padding.template.xsl

u can directly use this individual template by either cutting and pasting or
xsl:import ( u have to remember to either use the correct namespace if
importing ).

----- Original Message -----
From: "Tim Watts" <timw@3d3.com>
To: "XSL Mailing List (E-mail)" <XSL-List@lists.mulberrytech.com>
Sent: Monday, July 16, 2001 5:10 AM
Subject: [xsl] creating a string of repeated charactors


> I'm sure this must be a simple command, but how would something like a
> string of 8 charactors be output in XSLT.
>
> In ASP it might look something like
> String(8, "*")
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]