[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Total number of pages with XSL-FO

Subject: Re: Total number of pages with XSL-FO
From: JBryant@xxxxxxxxx
Date: Thu, 14 Apr 2005 13:44:01 -0500
fo block id
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:  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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.