xsl-list
[Top] [All Lists]

Re: [xsl] Kosher XSLT 3.0 numbering solution?

2016-09-01 10:27:11
On Thu, 2016-09-01 at 13:51 +0000, David Sewell dsewell(_at_)virginia(_dot_)edu
wrote:
 
   <xsl:variable name="bodyPageNo" select="0" as="xs:integer"
saxon:assignable="yes"/>
   <xsl:template match="pb">
     <xsl:variable name="pageNumber">
        <saxon:assign name="bodyPageNo" select="
           if (@n) then xs:integer(@n) else $bodyPageNo + 1
           "/>
        <xsl:value-of select="$bodyPageNo"/>
     </xsl:variable>

But surely it's not that hard to write a recursive template or function
that finds the previous page break and adds one to it where needed?
Roughly,

If this is the first page number then (@n, 1)[1]
If @n is supplied then @n
Otherwise 1 + pagenumber( (preceding::pagebreak)[1] )

If performance is an issue you can ask saxon to memoize (remember) the
function results.

Liam
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>