Re: [xsl] Line Numbering

Subject: Re: [xsl] Line Numbering
From: Steve <subsume@xxxxxxxxx>
Date: Fri, 4 Aug 2006 14:42:58 -0400
Hmm... you could use substring() and a recursive template.

That's what I'd do.

I'd start it off by something like

<xsl:call-template name="para">
  <xsl:with-param name="lineNumber" select="1" />
  <xs:with-param name="para" select="$para" />
</xsl:call-template>

<xsl:template name="para">
<xsl:param name="lineNumber">1</lineNumber>
</xsl:param name="para" />
<output line='{$lineNumber}' text="substring($para,0,29)" />
<xsl:if test="test if length of $para is greater than 29" >
  <xsl:call-template name="para">

  <xsl:with-param name="lineNumber" select="$lineNumber + 1"/>
  <xsl:with-param name="para" select="substring($para,30)" />
</xsl:call-template>
</xsl:if>
</xsl:template>

...approximately.

-S

On 8/4/06, Luke Jones <ljones@xxxxxxxxxxxxxxxxxx> wrote:
Hi,

I'm trying to number the lines of multiple paragraphs.

For example:
xml--
<bill>
...
<para>
FOR AN ACT relating to crimes and offenses; to amend sections 28-101,
28-201 and 28-932, Revised Statutes Cumulative Supplement, 2004; to
change provision relating to assault by a confined person; to create the
offense of assault...(etc)
</para>

I would need xsl code that makes the output look like so...

1       FOR AN ACT relating to crimes and offenses; to amend sections
2       28-101, 28-201 and 28-932, Revised Statutes Cumulative
3       Supplement, 2004; to change provision relating to assault by a
4       confined person; to creat the offense of assault...(etc)

Can anyone help me with this?  I just getting my feet wet with xsl, any
help would be much appreciated.

Thanks,
Luke

Current Thread