[xep-support] Re: CoolTool - Line Numbering

From: Kevin Brown <kevin@renderx.com>
Date: Wed Aug 27 2014 - 11:30:11 PDT

And attached is a sample output. As you can see at the very end, the issue
would exist with the last row of the table where it numbers 29-27-28. This
is because the last cell in that row is done first (yielding 27 and 28) then
the next cell with "higher" content is encountered (29). You would have this
limitation if you bottom align things and they vary in height.

Note: This also shows that the font-size of the number picks up from the
content encountered. You could certainly modify that behavior also in the
style sheet and use a fixed font size. You would need to implement this just
like the color, getting the previous value and outputting that back after
you put down the line number.

Kevin

-----Original Message-----
From: Xep-support [mailto:xep-support-bounces@renderx.com] On Behalf Of
Kevin Brown
Sent: Wednesday, August 27, 2014 11:18 AM
To: 'RenderX Community Support List'
Subject: [xep-support] CoolTool - Line Numbering

As I posted before, RenderX has an extension called "rx:ruler" that can be
used to lay down numbers on a page. This is not a true "line numberer", it
is a measuring stick. It was created for a very specific application
(legislation) and met the requirements of the customer. It was included into
XEP then and never documented, but it is there for all to use.

On another project, I developed an identity XSL that can be applied to the
RenderX Intermediate Format (XEPOUT) to understand lines of text and create
a numbering system. In XEPOUT, all text is represented by the <xep:text>
element. An <xep:text> element will also carry information on its position
(i.e. the "y" position on the page). A very simple 2.0 XSL can be used to go
through the document and inject line numbers at a specified location when an
<xep:text> element whose "y" is different from than last one. It is
important to have the "y" is different because you may have phrases on the
same line in different <xep:text> elements especially in the case of
kerning.

There are a few limitations in this method, specifically in the area of
tables. Tables in XEP rendered into XEPOUT do not necessarily follow
document order. You could design a table cell with say the cell contents
aligned to the bottom and have differing numbers of lines of text in the
cell. XEP outputs tables right to left, top to bottom and something like
this would get numbered incorrectly (the "Col" in "Col 3" would come before
the "Big" in "Big Col 2" in the XEPOUT.

       Big
Col Col Col
 1 2 3

The variable "xpos" is the X position where you want to line numbers.
I also had added a tolerance variable but did not have to implement it. You
certainly could do so. You would likely need it if you have
superscript/subscript.
The variable "numcolor" is a gray color value, you could of course do
something different.

This solution also makes use of adding <xep:pinpoint> elements into the
document to mark areas where you do not want to number. I used this for
excluding header/footer areas. One would do something like this in the
static-content areas. The pinpoints will be dropped into the XEPOUT to mark
the area where you do not want numbers,

<fo:static-content flow-name="xsl-region-before">
         <fo:block><rx:pinpoint value="notnumbered"/></fo:block>
         <fo:list-block font="10pt Helvetica"
provisional-distance-between-starts="5in"
provisional-label-separation="0in">
            <fo:list-item>
               <fo:list-item-label end-indent="label-end()">
                  <fo:block text-align="start" font-weight="bold"> Block
Properties - Borders </fo:block>
               </fo:list-item-label>
               <fo:list-item-body start-indent="body-start()">
                  <fo:block text-align="end">
                     Page <fo:page-number/>
                  </fo:block>
               </fo:list-item-body>
            </fo:list-item>
         </fo:list-block>
         <fo:block><rx:pinpoint value="numbered"/></fo:block>
      </fo:static-content>

Anyway, here is the sample XSL free for all to use and modify. If you find
it useful, great. Make any modifications and please post it back for all.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xep="http://www.renderx.com/XEP/xep"
    version="2.0">
    <xsl:variable name="xpos" select="10000"/>
    <xsl:variable name="tolerance" select="1000"/>
    <xsl:variable name="numcolor" select=".2"/>

    <xsl:template match="xep:text">
        <xsl:variable name="ypos" select="@y"/>
        <xsl:variable name="test1"
select="preceding-sibling::xep:text[not(@y=$ypos)]"/>
        <xsl:variable name="test2" select="distinct-values($test1/@y)"/>
        <xsl:variable name="linenum" select="count($test2) + 1"/>
        <xsl:variable name="numbering"
select="string(preceding-sibling::xep:pinpoint[1]/@value)"/>
        <!-- if the "Y" is unique, put down a linenumber -->
        <xsl:if test="not(preceding-sibling::xep:text/@y = $ypos) and
($numbering='' or $numbering='numbered')">
            <xep:gray-color gray="{$numcolor}"/>
            <xep:text x="{$xpos}" y="{$ypos}" value="{$linenum}"
width="7000"/>
            <xsl:copy-of select="preceding-sibling::*[contains(name(),
'color')]"/>
        </xsl:if>
        <xsl:copy-of select="."/>
    </xsl:template>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

_______________________________________________
(*) To unsubscribe, please visit
http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service
http://w ww.renderx.com/terms-of-service.html

_______________________________________________
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
ww.renderx.com/terms-of-service.html

Received on Wed Aug 27 18:43:50 2014

This archive was generated by hypermail 2.1.8 : Wed Aug 27 2014 - 18:43:50 PDT