You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Red Light <sk...@yahoo.com> on 2010/07/12 11:47:51 UTC

retrive a parameter in the xsl

Hi,

i want to obtain the pagination under this form:  Page 1 of 12
there is an interesting link in the Apache Fop FAQ http://xmlgraphics.apache.org/fop/fo.html#fo-total-pages

but i'm having trouble to get the wanted result , in my pdf rendering class
i do the tranformation 2 times , the first time i check if there is any problem with the xsl or the xml data then i got and generate the pdf wich is the final rendering so in the first one i retrieve the number of pages and i use the result in the second rendering.


//setup XSLT
TransformerFactory tranFactory = TransformerFactory.newInstance(); 
Transformer aTransformer = tranFactory.newTransformer(xsltfile); 
aTransformer.setParameter("page-count",nbrPages);				 
 aTransformer.transform(src, res); 
System.out.println("getParameter : "+aTransformer.getParameter("page-count"));


it works the print print the number of pages now in my xslt

i declare a variable like:
<xsl:variable name="page-count"></xsl:variable>

and i'm trying to print it:

<xsl:value-of select="$page-count" />	

but no result(i'm feeling like missing something btu what ;d?) ?


and thanks a lot





      


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


RE: retrive a parameter in the xsl

Posted by Eric Douglas <ed...@blockhouse.com>.
Rather than trying to transform it twice so the second time knows the
number of pages, I found the simplest way to get the page count is to
force a page reference onto the last page.

...
                    </xsl:for-each>
               </xsl:for-each>
               <fo:block>
                    <xsl:attribute name="id">last-page</xsl:attribute>
                    <xsl:attribute
name="position">absolute</xsl:attribute>
                    <xsl:attribute name="left">0</xsl:attribute>
                    <xsl:attribute name="top">0</xsl:attribute>
                    <xsl:attribute name="width">0</xsl:attribute>
                    <xsl:attribute name="height">0</xsl:attribute>
               </fo:block>
          </fo:flow>
...
Then where I want to put the last page number into my text, I put a page
number variable I made up into my text tag in the xml:

                    <xsl:for-each select="TEXT">
                         <xsl:choose>
                              <xsl:when test="VARIABLE =
'%CURRENT_PAGE%'"><fo:page-number /></xsl:when>
                              <xsl:when test="VARIABLE =
'%LAST_PAGE%'"><fo:page-number-citation ref-id="last-page"/></xsl:when>
                              <xsl:otherwise><xsl:value-of
select="."/></xsl:otherwise>
                         </xsl:choose>
                    </xsl:for-each>
 

-----Original Message-----
From: Red Light [mailto:skydelta98@yahoo.com] 
Sent: Monday, July 12, 2010 5:48 AM
To: fop-users@xmlgraphics.apache.org
Subject: retrive a parameter in the xsl 

Hi,

i want to obtain the pagination under this form:  Page 1 of 12 there is
an interesting link in the Apache Fop FAQ
http://xmlgraphics.apache.org/fop/fo.html#fo-total-pages

but i'm having trouble to get the wanted result , in my pdf rendering
class i do the tranformation 2 times , the first time i check if there
is any problem with the xsl or the xml data then i got and generate the
pdf wich is the final rendering so in the first one i retrieve the
number of pages and i use the result in the second rendering.


//setup XSLT
TransformerFactory tranFactory = TransformerFactory.newInstance();
Transformer aTransformer = tranFactory.newTransformer(xsltfile); 
aTransformer.setParameter("page-count",nbrPages);

 aTransformer.transform(src, res);
System.out.println("getParameter :
"+aTransformer.getParameter("page-count"));


it works the print print the number of pages now in my xslt

i declare a variable like:
<xsl:variable name="page-count"></xsl:variable>

and i'm trying to print it:

<xsl:value-of select="$page-count" />	

but no result(i'm feeling like missing something btu what ;d?) ?


and thanks a lot





      


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: retrive a parameter in the xsl

Posted by Red Light <sk...@yahoo.com>.
Hi Pascal,


thanks
 


      


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: retrive a parameter in the xsl

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi,
what you need is xsl:param instead of xsl:variable. the syntax is the
same for both elements.
Note that this list is for FOP usage; to ask XSLT questions, the list
cited in [1] is more relevant.

[1] http://mulberrytech.com/xsl/xsl-list/

Pascal

Le 12/07/2010 11:47, Red Light a écrit :
> Hi,
>
> i want to obtain the pagination under this form:  Page 1 of 12
> there is an interesting link in the Apache Fop FAQ http://xmlgraphics.apache.org/fop/fo.html#fo-total-pages
>
> but i'm having trouble to get the wanted result , in my pdf rendering class
> i do the tranformation 2 times , the first time i check if there is any problem with the xsl or the xml data then i got and generate the pdf wich is the final rendering so in the first one i retrieve the number of pages and i use the result in the second rendering.
>
>
> //setup XSLT
> TransformerFactory tranFactory = TransformerFactory.newInstance(); 
> Transformer aTransformer = tranFactory.newTransformer(xsltfile); 
> aTransformer.setParameter("page-count",nbrPages);				 
>  aTransformer.transform(src, res); 
> System.out.println("getParameter : "+aTransformer.getParameter("page-count"));
>
>
> it works the print print the number of pages now in my xslt
>
> i declare a variable like:
> <xsl:variable name="page-count"></xsl:variable>
>
> and i'm trying to print it:
>
> <xsl:value-of select="$page-count" />	
>
> but no result(i'm feeling like missing something btu what ;d?) ?
>
>
> and thanks a lot
>
>
>
>
>
>       
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
> .
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org