[xsl] FW: XSL-FO: reset fo:page-number to 1 in each section of .pdf, ba sed on XML input

Subject: [xsl] FW: XSL-FO: reset fo:page-number to 1 in each section of .pdf, ba sed on XML input
From: "Greenbaum, Bill" <Bill@xxxxxxxxxxxx>
Date: Mon, 7 Apr 2003 17:19:39 -0400
> Objective: Generate a .pdf with FOP, showing the <fo:page-number/>
> reverting to 1 on the first page for each BIRD.
> 
> What I get now: The output .pdf displays page numbers running
> consecutively from 1 at the beginning output to the end of the entire
> output.
> 
> Environment: Win, Apache's FOP-0.20.4 tool, generating a .pdf from an .XML
> file and an .XSL file (see samples below), . 
> 
> XML input: Each DOCUMENT/ITEM tag contains one BIRD tag with other data
> pertaining to that BIRD.  Different ITEMs can contain the same BIRD value.
> For each FOP transformation, I don't know in advance how many different
> BIRDs will occur in the XML, nor how many <ITEM>-level tags will pertain
> to the same BIRD value.   I'd like to assume I don't need to restructure
> the XML to reach our objective (correct pagination).
> 
>   <DOCUMENT>
> 		<ITEM>
> 			<BIRD>15</BIRD>
> 			<LICENSE>11432</LICENSE>
> 			<COLOR>Brown</COLOR>
> 		</ITEM>
> 		<ITEM>
> 			<BIRD>15</BIRD>
> 			<LICENSE>21435</LICENSE>
> 			<COLOR>White</COLOR>
> 		</ITEM>
> 		<ITEM>
> 			<BIRD>10</BIRD>
> 			<LICENSE>17865</COLOR>
> 			<COLOR>Blue</COLOR>
> 		</ITEM>
> 		<ITEM>
> 			<BIRD>10</BIRD>
> 			<LICENSE>17912</LICENSE>
> 			<COLOR>Red</COLOR>
> 		</ITEM>
> 		<ITEM>
> 			<BIRD>10</BIRD>
> 			<LICENSE>18012</LICENSE>
> 			<COLOR>Yellow</COLOR>
> 		</ITEM>
>   </DOCUMENT>
> 
> XSL-FO excerpt:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>   xmlns:fo="http://www.w3.org/1999/XSL/Format";>
> <xsl:variable name="uniqueBirds" select="DOCUMENT/ITEM[not(BIRD =
> preceding::BIRD)]/BIRD"/> 
> <xsl:template match="/">
> <fo:root>
>   <fo:layout-master>
>      	<fo:simple-page-master master-name="simpleFirst"
> 		 page-height="11in" 
>                  page-width="8.5in"
>                  margin-top="1cm" 
>                  margin-bottom="1.5cm" 
> 		 margin-left="25px" 
>                  margin-right="25px">  
> 		....
>      	</fo:simple-page-master>     
> 
>      	<fo:simple-page-master master-name="simpleRest"
> 		 page-height="11in" 
>                  page-width="8.5in"
>                  margin-top="1cm" 
>                  margin-bottom="1.5cm" 
> 		 margin-left="25px" 
>                  margin-right="25px">  
> 		....
>      	</fo:simple-page-master>     
> 
> 	<fo:simple-page-master master-name="simpleLast"
> 		 page-height="11in" 
>                  page-width="8.5in"
>                  margin-top="1cm" 
>                  margin-bottom="1.5cm" 
> 		 margin-left="25px" 
>                  margin-right="25px">  
> 		....      
>      	</fo:simple-page-master>     
> 
> 
> 	<fo:page-sequence-master master-name="simplePS1"
> initial-page-number="1">   	 	    
> 		<fo:repeatable-page-master-alternatives>
> 			<fo:conditional-page-master-reference
> master-reference="simpleFirst"
> 					page-position="first"/>
> 
> 			<fo:conditional-page-master-reference
> master-reference="simpleRest"
> 					page-position="rest"/><!--
> continuation page for data of each BIRD if needed -->			
> 			<fo:conditional-page-master-reference
> master-reference="simpleLast"
> 					page-position="last"/><!-- static
> last page of each BIRD -->					
> 		</fo:repeatable-page-master-alternatives>	
> 	</fo:page-sequence-master>  
>    </fo:layout-master-set>
> 
>    <fo:page-sequence master-reference="simplePS1" initial-page-number="1">
> 
>    	 <fo:static-content flow-name="xsl-region-before">
> 		<fo:block>Page <fo:page-number/> </fo:block>
>    	 </fo:static-content>
>    	 		
>    	 <fo:flow flow-name="xsl-region-body">
>    		<fo:block><xsl:apply-templates select="*"/></fo:block>
> 
>    	 </fo:flow>   	   	 
>    </fo:page-sequence>
> </fo:root> 
> ...
> </xsl:template>
> Note appended to the above xsl-fo:
>    .pdf output looks the same when I enclose the
> <fo:page-sequence></fo:page-sequence> or the <fo:root></fo:root> in
>    <xsl:for-each select="DOCUMENT[ITEM/BIRD =
> $uniqueBirds]"><xsl:for-each>.
> 
> Desired .pdf output:
> 
> Page in
> the output	The page
> sequence	should display
> 
> 1	  	page# = 1
> 		BIRD = 15
> 		COLOR = Brown
> 
> 2	  	page# = 2
> 		BIRD = 15
> 		COLOR = White
> 
> 3		page# = 3
> 		BIRD = 15
> 		Static Last Page for each BIRD
> 
> 4	  	page# = 1
> 		BIRD = 10
> 		COLOR = Blue
> 
> 5	  	page# = 2
> 		BIRD = 10
> 		COLOR= Red
> 
> 6	  	page# = 3
> 		BIRD = 10
> 		COLOR= Yellow
> 
> 7		page# = 4
> 		BIRD = 10
> 		Static Last Page for each BIRD
> 
> 
> 
> 
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread