Re: [xsl] Total number of pages with XSL-FO

Subject: Re: [xsl] Total number of pages with XSL-FO
From: Nadia.Swaby@xxxxxx
Date: Tue, 19 Apr 2005 12:34:27 -0400
Hello Everyone,

Thanks for all the help.  Jay's suggestion below worked great!  I did try
fo:wrapper just for kicks, and it did not work.
Now, on to other XML and XSL problems....

Nadia


                                                                                                                             
                      JBryant@xxxxxxxx                                                                                       
                      m                        To:      xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                      
                                               cc:                                                                           
                      2005-04-14 14:44         Subject: Re: [xsl] Total number of pages with XSL-FO                          
                      Please respond                                                                                         
                      to xsl-list                                                                                            
                                                                                                                             
                                                                                                                             




Hi, Nadia,

You are generating the .fo document from an XML source via an XSL
stylesheet, right? So how can the last-page block be in the fo already? I
must not have a proper grasp of your process.

Anyway, to make page x of y work correctly, you need to put in an empty
block with the ID, as your predecessor mentioned. If you put the ID on an
actual content block, you run the risk of the content within the block
crossing a page boundary and making your page total be off by one (or more
if you have a really big block). Fortunately, you can make the empty block
be very small, so that it is unlikely to trigger a new page. Try this:

<fo:block id="last-page" line-height="0"/>

If you want to be absolutely sure that content appears on the last page,
put the last block that has content and the empty block into a table that
has two rows (one for each block). Then set keep-with-next="always" on the
first row. That way, the empty block can never be on a page by itself.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




Nadia.Swaby@xxxxxx
04/14/2005 12:12 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re: [xsl] Total number of pages with XSL-FO







Well I tried and it does not work.  I suspect that it is because the id
'last-page' is in the actual .fo document, no in the xml.

here is a code snippet:

<xsl:choose>
      <xsl:when test="//fo:block/@id='last-page'">
            Page <fo:page-number/> of <fo:page-number-citation
ref-id="last-page"/>
      </xsl:when>
      <xsl:otherwise>
            Page 1 of 1
      </xsl:otherwise>
</xsl:choose>


<!--snip to block with id='last-page'-->

<fo:static-content flow-name="xsl-region-after-otherlast">
      <fo:block id="last-page" space-before="12pt"
keep-together.within-page="auto">
            <fo:leader leader-pattern="rule" leader-length="100%"
rule-thickness="0.5pt" rule-style="solid" color="black"/>
      </fo:block>
</fo:static-content>


Somehow, I think there is no way to get that xsl:choose to work.

I talked to the guy that worked on this before me.  The original
stylesheet
had an empty block at the end of the document and that block had the id
set
to "last-page".  The problem was that it cause a new empty page to be
displayed in some cases, and it was taken out.

My guess is that I am going to have to take it out and hope that the
custodians and users do not mind just having a page number, instead of the
total number of pages.

Nadia Swaby




                      JBryant@xxxxxxxx
                      m                        To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
                                               cc:
                      2005-04-14 11:43         Subject: Re: [xsl] Total
number of pages with XSL-FO
                      Please respond
                      to xsl-list






> So here is my next question: is there any way to see if an id
> exists in an FO document?
>
> Nadia Swaby

Hi, Nadia,

Sure. You can do a test for it in either xsl:when or xsl:if. For example:

<xsl:if test="//@id='MyID'">
  <!-- Do something (perhaps apply certain templates) -->
</xsl:if>

Of course, if you can determine the exact path (not always possible
because elements may be nested at different depths and so on), you can use
the actual path instead of //.

HTH

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

Current Thread