You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by s-...@artefrance.fr on 2003/02/17 21:51:09 UTC

Can't bind page number into a variable

Hi,

I would like to put specific attributes on odd or even pages, so I began 
by looking for a way to check the context pages but I did'nt find 
anything. 

So I wanted to bind the <fo:page-number /> into a variable in order to 
make some test on it when I want to add specific parameters to my tags.

<xsl:variable name="page_number"><fo:page-number /></xsl:variable>
<xsl:if test="($page_number mod 2)=1">
  <xsl:attribute name="text-align">start</xsl:attribute>
</xsl:if>
<xsl:if test="($page_number mod 2)=0">
  <xsl:attribute name="text-align">end</xsl:attribute>
</xsl:if>

But it looks like being impossible to bind the <fo:page-number /> into a 
variable or param (I tried to write my variable in a block but it looks 
like being setted to "" by the fo:page-number tag). 

Is here a reason for my variable to be null ? And is there a way to detect 
the context where I am currently in while writing in a non-static content 
?

I also tried to make a template with a page_number param but it doesn't 
work either...

Here are some examples of my pdf outputs :

http://www.tatouage.fr/temp/ap_skin_example.pdf
(here I want to align my titles at the start or the end of the block 
depending of the odd or even condition, I am in a non-static context)

http://www.tatouage.fr/temp/cd_skin_example.pdf
(It's the same with this skin but it will be easier for me because every 
objects have statical position on the page = I have one odd and one even 
page for each XML <FICHE> tag, so I'll be able to manage the whole page 
breaking in XSLT)

Sorry for disturbing you developpers with my little problem, but it makes 
me so nervous ... :/

Thanks for your work on this API.

Simon OUALID


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


RE: Can't bind page number into a variable

Posted by "Volker Reichel@vrsoft.de" <vo...@VRSoft.de>.
Hi Simon,

I'm afraid but there is no way to know on which page you are.
Is there a reason why you can't put the page number into a static area?
If you can then the following snippets might help:


1. Define your pages (left / right)

<fo:simple-page-master master-name="right_page"
page-height="{$MEDIA_PAGE_HEIGHT}cm" page-width="{$MEDIA_PAGE_WIDTH}cm"
margin-top="{$MEDIA_MARGIN_TOP}cm" margin-bottom="{$MEDIA_MARGIN_BOTTOM}cm"
margin-left="{$MEDIA_MARGIN_LEFT}cm" margin-right="{$MEDIA_MARGIN_RIGHT}cm">
	<fo:region-body margin-top="{$SUBSIDIARIES_HEADER_EXTENT}cm"
margin-bottom="{$SUBSIDIARIES_FOOTER_EXTENT}cm"
margin-left="{$THUMB_AREA_EXTENT}cm" margin-right="{$THUMB_AREA_EXTENT}cm">
					<xsl:call-template name="makeBackgroundImage"/>
				</fo:region-body>
				<fo:region-before extent="{$SUBSIDIARIES_HEADER_EXTENT}cm"/>
				<fo:region-after region-name="footer-even"
extent="{$SUBSIDIARIES_FOOTER_EXTENT}cm"/>
				<fo:region-start extent="{$THUMB_AREA_EXTENT}cm"/>
				<fo:region-end extent="{$THUMB_AREA_EXTENT}cm"/>
</fo:simple-page-master>

			<fo:simple-page-master master-name="left_page"
page-height="{$MEDIA_PAGE_HEIGHT}cm" page-width="{$MEDIA_PAGE_WIDTH}cm"
margin-top="{$MEDIA_MARGIN_TOP}cm" margin-bottom="{$MEDIA_MARGIN_BOTTOM}cm"
margin-left="{$MEDIA_MARGIN_LEFT}cm" margin-right="{$MEDIA_MARGIN_RIGHT}cm">
				<fo:region-body margin-top="{$SUBSIDIARIES_HEADER_EXTENT}cm"
margin-bottom="{$SUBSIDIARIES_FOOTER_EXTENT}cm"
margin-left="{$THUMB_AREA_EXTENT}cm" margin-right="{$THUMB_AREA_EXTENT}cm">
					<xsl:call-template name="makeBackgroundImage"/>
				</fo:region-body>
				<fo:region-before extent="{$SUBSIDIARIES_HEADER_EXTENT}cm"/>
				<fo:region-after region-name="footer-odd"
extent="{$SUBSIDIARIES_FOOTER_EXTENT}cm"/>
				<fo:region-start extent="{$THUMB_AREA_EXTENT}cm"/>
				<fo:region-end extent="{$THUMB_AREA_EXTENT}cm"/>
			</fo:simple-page-master>



2. Assign them to odd / even page numbers

<fo:page-sequence-master master-name="subsidiaries">
	<fo:repeatable-page-master-alternatives>
		<fo:conditional-page-master-reference master-reference="right_page"
odd-or-even="odd"/>
		<fo:conditional-page-master-reference master-reference="left_page"
odd-or-even="even"/>	</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>


3. Use the page sequence and add layout specific to even / odd pages

<fo:page-sequence master-reference="subsidiaries">
			<fo:static-content flow-name="footer-even">
				<xsl:call-template name="makeNotesFootnote"/>
				<xsl:call-template name="makePageNumberFooterEven"/>
			</fo:static-content>
			<fo:static-content flow-name="footer-odd">
				<xsl:call-template name="makeNotesFootnote"/>
				<xsl:call-template name="makePageNumberFooterOdd"/>
			</fo:static-content>
			<fo:flow>
				...
			</fo:flow>
</fo:page-sequence>


BTW: Please use fop-users list for questions like this in future.


-----Original Message-----
From: s-oualid@artefrance.fr [mailto:s-oualid@artefrance.fr]
Sent: Monday, February 17, 2003 9:51 PM
To: fop-dev@xml.apache.org
Subject: Can't bind page number into a variable


Hi,

I would like to put specific attributes on odd or even pages, so I began
by looking for a way to check the context pages but I did'nt find
anything.

So I wanted to bind the <fo:page-number /> into a variable in order to
make some test on it when I want to add specific parameters to my tags.

<xsl:variable name="page_number"><fo:page-number /></xsl:variable>
<xsl:if test="($page_number mod 2)=1">
  <xsl:attribute name="text-align">start</xsl:attribute>
</xsl:if>
<xsl:if test="($page_number mod 2)=0">
  <xsl:attribute name="text-align">end</xsl:attribute>
</xsl:if>

But it looks like being impossible to bind the <fo:page-number /> into a
variable or param (I tried to write my variable in a block but it looks
like being setted to "" by the fo:page-number tag).

Is here a reason for my variable to be null ? And is there a way to detect
the context where I am currently in while writing in a non-static content
?

I also tried to make a template with a page_number param but it doesn't
work either...

Here are some examples of my pdf outputs :

http://www.tatouage.fr/temp/ap_skin_example.pdf
(here I want to align my titles at the start or the end of the block
depending of the odd or even condition, I am in a non-static context)

http://www.tatouage.fr/temp/cd_skin_example.pdf
(It's the same with this skin but it will be easier for me because every
objects have statical position on the page = I have one odd and one even
page for each XML <FICHE> tag, so I'll be able to manage the whole page
breaking in XSLT)

Sorry for disturbing you developpers with my little problem, but it makes
me so nervous ... :/

Thanks for your work on this API.

Simon OUALID


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org