← Prev in month ← Prev in thread
Next in thread → Next in month →

AW: [docbook-apps] line numbering with xsltproc

From
"Rtock, Kan"
Date
2008-11-13T10:25:48+00:00
ID
Thread
AW: [docbook-apps] line numbering with xsltproc
Hello Bob,

 

thank you so much for that
great template and the immediate reply! It works. But there is still a problem and
I can’t find a solution:

Your choose condition
searches the “break” with the “
” entity. But
in my case I often don’t have any brakes and the result looks like this (blocks
are numbered):

 

01                                kldsjf
lkdsjf kldsj fkldjslkf jdslkjf lkdsjf ljdslk fjdlsk jflksdj flksdjlkf jlkdsjf
lkdsjl kfjdslkjf lkdsj lkfjdslkf jlkdsjf lkdsjlfk dslkf j  

                                   Kfkldsjflk
jdsf lkdsj klfdsjlkf jdlksj flkdsj lkdjs klfjdslk jflkdsj flkdjslfk jdslkj
lkdsj lkdsj flkjdsjf lkdsj lkfdsj lkfjdslkjf lkdsj dlskj f

                                   Lkjfslkdjflkdsj
lkdsjf lkdsj flkdsj lkfdsj klfdjslk fjdlskjf lkdsj lkdjs fj

 

02                                kdsfklsdjflkjdslkfj
ldsjf lkdsj lkfdsjlk fjdslkj flkdsjlk fjdslkjf lkdsj lkdsj fkljdslkfj lkdsjf
lkjdslkf jlkdsj lkdsjf 

 

03                                ksjfdklsj
lksdjf kldsjf lkdsjkfl jdslk fjlkdsj flkdsj lkfdjslkf dklsf jlkdsjf lkdsjlkf
jdlksjf lkdsjlf kdjslfk jdlksfj lkdsjf lkdsjlkf djslk jlds

                                   Skdf
lkjdsf jkdnskjf ndsjkf jkdsf jkdsnjf ndsjkf dskjnkjfdsnkjsn

 

So here is my question:
Could you explain me in which template the line breaks are set in Docbook? Or
do you know an other solution for this specific problem?

Thank you very much for that great support!

 

Regards,

Jan  

 

Von: Bob Stayton
[mailto:] 

Gesendet: Dienstag, 11. November 2008
18:44

An: Stock, Jan;


Betreff: 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,
'&#xA;')">

      <xsl:value-of
select="substring-before($content, '&#xA;')"/>

      <xsl:text>&#xA;</xsl:text>

 

      <xsl:variable
name="rest" select="substring-after($content,
'&#xA;')"/>

      <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>

 

 

 

Bob Stayton

Sagehill Enterprises



 

 

----- Original Message ----- 

From: Stock,
Jan 

To: 

Sent: Tuesday, November
11, 2008 6:01 AM

Subject: [docbook-apps]
line numbering with xsltproc

 

Hello,

I am trying to insert line numbering in my
PDFs. I read that only Saxon
and Xalan provide that function. Does anyone know how to implement line
numbering in DocBook XML files which are parsed with xsltproc?

I would be pleased to receive any help concerning that problem. My extensive
online search resulted in no solution.

Regards,

Jan

 

******************************************* 

Harman Becker Automotive Systems GmbH 

Management Board: Dr. Klaus Blickle (Chairman), Dr. Udo Hüls, Michael
Mauser, Regis Baudot 

Chairman of the Supervisory Board: Ansgar Rempp | Domicile: Karlsbad | 

Local Court Mannheim: Register No. 361395 

  

*******************************************

Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und
loeschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe
dieser Mail ist nicht gestattet. 

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and delete this e-mail. Any unauthorized
copying, disclosure or distribution of the contents in this e-mail is strictly
forbidden. 

*******************************************
← Prev in month ← Prev in thread
Next in thread → Next in month →