[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] line numbering with xsltproc
You try something like this in a customization
layer. It is not extensively tested. It recursively parses the text node in a
programlisting based on the line ending character 
, inserts the line
number, and recurses to the next line.
<xsl:template
match="programlisting/text()">
<xsl:call-template name="line.numbering"> <xsl:with-param name="content" select="."/> <xsl:with-param name="count" select="1"/> </xsl:call-template> </xsl:template> <xsl:template
name="line.numbering">
<xsl:param name="content" select="."/> <xsl:param name="count" select="1"/> <xsl:number value="$count" format="01
"/>
<xsl:choose>
<xsl:when test="contains($content, '
')"> <xsl:value-of select="substring-before($content, '
')"/> <xsl:text>
</xsl:text> <xsl:variable
name="rest" select="substring-after($content,
'
')"/>
<xsl:if test="string-length($rest)"> <xsl:call-template name="line.numbering"> <xsl:with-param name="content" select="$rest"/> <xsl:with-param name="count" select="$count + 1"/> </xsl:call-template> </xsl:if> </xsl:when> <xsl:otherwise> <!-- we are done --> <xsl:value-of select="$content"/> </xsl:otherwise> </xsl:choose> </xsl:template>
|
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]