This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Indent based on position()
- From: "Kirk Allen Evans" <kaevans at xmlandasp dot net>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 11 Apr 2002 08:10:16 -0700
- Subject: Re: [xsl] Indent based on position()
- References: <008001c1e14c$7012aa00$b123adc3@MWRWD9>
- Reply-to: xsl-list at lists dot mulberrytech dot com
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="content/line"/>
</xsl:template>
<xsl:template match="line">
<!-- Concatenate with a bunch of dashes -->
<xsl:variable name="dashes" select="'---------------------'"/>
<!-- Take the number of dashes corresponding to the line's position
number -->
<xsl:value-of select="substring($dashes,1,position())"/>
<xsl:value-of select="."/>
<!-- Carriage-return-->
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
Kirk Allen Evans
kaevans@xmlandasp.net
"XML and ASP.NET", New Riders Publishing
Available at Amazon.com
http://www.amazon.com/exec/obidos/ASIN/073571200X/
----- Original Message -----
From: "Brook Elgie" <brook.elgie@mwr.biz>
To: <XSL-List@lists.mulberrytech.com>
Sent: Thursday, April 11, 2002 4:31 AM
Subject: [xsl] Indent based on position()
> Hello all,
>
> I've got the XML code:
>
> <content>
> <line>This is the first line</line>
> <line>This is the second line</line>
> <line>This is the third line</line>
> <line>This is the forth and last line</line>
> </content>
>
> And would like the html output:
>
> <p>
> -This is the first line<br/>
> --This is the second line<br/>
> ---This is the third line<br/>
> ----This is the forth line<br/>
> </p>
>
> So, when i process each <line> I need to duplicate the "-" character as
many
> times as the position() of the <line> being processed, I think. Can I do
> this?
>
> cheers
> brook
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list