Hi,
Some years ago, Bob Stayton sent me a piece of code to allow the display
of the string page X of Y at the bottom of each chunk (see exchanges
below). It worked perfectly. At that time I was using docbook-xsl-1.68.1
but since then I did regular updates and I am now using
docbook-xsl-1.73.2. I have been asked to update the old document for
which this special footer is needed but the output is no longer the one
desired: I obtain /page of 0 /at the bottom of each page. I don't know
which update broke the compatibility and I have problem understanding
what I should modify. It seems the following lines are no longer
processed correctly:
!-- Turn the chunk hierarchy into a node-set --
xsl:variable name=mychunks
select=exsl:node-set($mychunk.hierarchy)//div/
!-- Get the total number of chunks --
xsl:variable name=chunk.total select=count($mychunks)/
Any idea?
Thanks in advance.
Diane Larin
INRO
Bob Stayton wrote:
Well, I never know how much information to give because list participants
have a wide range of experience with XSL. 8^)
Here is a sample customization of 'user.footer.content'. The first three
variables are global (not inside a template), so they are computed once when
the stylesheet starts.
!-- Create the chunk hierarchy --
xsl:variable name=mychunk.hierarchy
xsl:if test=function-available('exsl:node-set')
xsl:messageComputing chunks.../xsl:message
xsl:apply-templates select=/* mode=find.chunks/
/xsl:if
/xsl:variable
!-- Turn the chunk hierarchy into a node-set --
xsl:variable name=mychunks
select=exsl:node-set($mychunk.hierarchy)//div/
!-- Get the total number of chunks --
xsl:variable name=chunk.total select=count($mychunks)/
!-- Add a line to the footer --
xsl:template name=user.footer.content
!-- Get the id of the current chunk --
xsl:variable name=genid select=generate-id()/
!-- Get the position of the current chunk.
You have to switch contexts using xsl:for-each to
get the position within the node-set. --
xsl:variable name=X
xsl:for-each select=$mychunks
xsl:if test=@id = $genid
xsl:value-of select=position()/
/xsl:if
/xsl:for-each
/xsl:variable
!-- Output the numbers --
div class=nodecount
xsl:textNode /xsl:text
xsl:value-of select=$X/
xsl:text of /xsl:text
xsl:value-of select=$chunk.total/
/div
/xsl:template
I originally thought iterating over all the chunks using xsl:for-each would
slow things down, since it is done for each chunk. But my tests show it
doesn't affect processing time much, even for a 400 chunk document.
Bob Stayton
Sagehill Enterprises
DocBook Consulting
[EMAIL PROTECTED]
- Original Message -
From: Diane Larin [EMAIL PROTECTED]
To: docbook-apps@lists.oasis-open.org
Sent: Thursday, March 31, 2005 4:32 PM
Subject: Re: [docbook-apps] Page X of Y in user.footer.navigation
I had a look at the 'process-chunk-element' template but I find
it quite cryptic (I don't have a lot of experience in writing/modifying
XSL stylesheets). I was expecting that I was not the first one to have
this need and that a recipe would exist :-(
Diane Larin
INRO
On Wed, 30 Mar 2005, Bob Stayton wrote:
I think this could be done by borrowing some of the chunkfast code.
It
precomputes a node-set of all the chunks. Once you have that, you
could
count the nodes to get Y, and figure out the position of the current
chunk
in the node-set to get X. Take a look at the first part of the
template
named 'process-chunk-element' in html/chunk-code.xsl. It shows how to
process nodes in the chunk node-set.
Bob Stayton
Sagehill Enterprises
DocBook Consulting
[EMAIL PROTECTED]
- Original Message -
From: Diane Larin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, March 30, 2005 7:06 AM
Subject: Re: [docbook-apps] Page X of Y in user.footer.navigation
I'm not sure I understand. There are no page numbers in chunked
HTML.
Do you mean to label the chunks with a sequence number X, with Y
being
the total number of chunks?
Exactly. This is for a tutorial where we want to be able to inform
the user what remains to be done.
Diane Larin
INRO