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 Eric Douglas <ed...@blockhouse.com> on 2010/08/05 14:26:37 UTC

XSL Page Variable

If the shell of my XSL looks like this: 
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format
<http://www.google.com/url?sa=D&q=http://www.w3.org/1999/XSL/Format&usg=
AFQjCNHZhPMfx2p6D5n2w5qLURB5k932Cw> "> 
<fo:layout-master-set> 
<fo:simple-page-master> 
<xsl:attribute name="master-name">STANDARD_PAGE</xsl:attribute> 
<xsl:attribute name="margin-bottom"><xsl:value-of 
select="PAGE_DATA/MARGIN_BOTTOM"/></xsl:attribute> 
<fo:region-body> 
</fo:region-body> 
</fo:simple-page-master> 
</fo:layout-master-set> 
<fo:page-sequence> 
<xsl:attribute name="master-reference">STANDARD_PAGE</xsl:attribute> 
<fo:flow> 
<xsl:attribute name="flow-name">xsl-region-body</xsl:attribute> 
<xsl:for-each select="PAGE_DATA"> 
<fo:block> 
<xsl:attribute name="break-before">page</xsl:attribute> 
<xsl:for-each select="*"> 
... 
</xsl:for-each> 
</fo:block> 
</xsl:for-each> 
</fo:flow> 
</fo:page-sequence> 
</fo:root> 
So I have all my data grouped by what to print on each page, under a 
PAGE_DATA tag in the XML. Now I'm trying to put a tag under the 
PAGE_DATA tag to specify different attributes for each page, such as 
the margin-bottom mentioned here. As it is written here, it is using 
the value of the MARGIN_BOTTOM tag for the margin-bottom attribute, 
but it's only taking the last tag in the XML and applying it to all 
pages. How do I change the attributes for each page? 
Is there a place where I can set a variable from the XML tag value 
which can be processed after the for-each statement and before the 
page attributes? 

Re: XSL Page Variable

Posted by "Christopher R. Maden" <cr...@maden.org>.
Eric Douglas wrote:
> I'm not entirely sure I know what you mean by what the FO markup should
> look like.  If you mean the XSLFO file, I never see that.  I'm running
> embedded code, where I just create an XML file and an XSL file and pass
> them right through the FOP with the transformer.  Assuming there is
> XSLFO code, it's in memory, and I'm not sure what the option would be to
> create a physical file.

FOP works on an XML file using XSL-FO markup to generate output.

You are using XML and XSLT to generate the XML-FO.  This is happening in
memory, using some XSLT processor (probably Xalan, the default for FOP).

You can also run that same pair of XML and XSLT directly and capture the
output in a file.  That is much more helpful to those trying to help you
with FOP, as it is then very clear exactly what FOP is processing.

> I thought it might be a dev issue because I'm not sure if I coded
> something wrong or FOP processed it wrong.

If it is a FOP bug, the developers will want an FO sample in any case.

> Now, maybe there's something I'm not understanding about XSL, maybe I
> can write the XSL backward?  It's currently driven by the page-sequence
> which tells it which page-master to use, which defines the layout.  Then
> within that I have the loop where everything under a PAGE_DATA tag goes
> on one page.  How would I arrange this so every page has the option to
> be either portrait or landscape?

I would work backward.  If you can come up with a simple example FO that
does what you want in FOP, you can then figure out how to make an XSLT
that will generate that FO.  If you are not sure what FO you need, you
will have a lot of difficulty figuring out the right XSLT.  Separation
of layers is almost always helpful to understanding.

~Chris
-- 
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
“I like being free, and that makes me an idiot, I suppose.”
  — Stan Rogers, “The Idiot”
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319

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


RE: XSL Page Variable

Posted by Eric Douglas <ed...@blockhouse.com>.
Hi Chris,

I'm not entirely sure I know what you mean by what the FO markup should
look like.  If you mean the XSLFO file, I never see that.  I'm running
embedded code, where I just create an XML file and an XSL file and pass
them right through the FOP with the transformer.  Assuming there is
XSLFO code, it's in memory, and I'm not sure what the option would be to
create a physical file.
I thought it might be a dev issue because I'm not sure if I coded
something wrong or FOP processed it wrong.

I'm trying to code into my XML what goes on each page and what the page
format should be.  I thought I might need multiple page masters and/or
page sequences but I'm not sure how I would reference them.  The XSL
code looks something like this (leaving out some unrelated pieces).

     <fo:layout-master-set>
          <fo:simple-page-master>
               <xsl:attribute
name="master-name">STANDARD_PAGE</xsl:attribute>
               <xsl:attribute name="reference-orientation">
                    <xsl:choose>
                         <xsl:when
test="PAGE_DATA[position()]/ORIENTATION = 'PORTRAIT'">0</xsl:when>
                         <xsl:when
test="PAGE_DATA[position()]/ORIENTATION = 'LANDSCAPE'">90</xsl:when>
                    </xsl:choose>
               </xsl:attribute>
               <fo:region-body>
               </fo:region-body>
          </fo:simple-page-master>
     </fo:layout-master-set>
     <fo:page-sequence>
     <xsl:attribute
name="master-reference">STANDARD_PAGE</xsl:attribute>
          <fo:flow>
               <xsl:attribute
name="flow-name">xsl-region-body</xsl:attribute>
               <xsl:for-each select="PAGE_DATA">
                    <xsl:variable name="ORIENTATION"><xsl:value-of
select="ORIENTATION"/></xsl:variable> 

Now, maybe there's something I'm not understanding about XSL, maybe I
can write the XSL backward?  It's currently driven by the page-sequence
which tells it which page-master to use, which defines the layout.  Then
within that I have the loop where everything under a PAGE_DATA tag goes
on one page.  How would I arrange this so every page has the option to
be either portrait or landscape?

-----Original Message-----
From: Christopher R. Maden [mailto:crism@maden.org] 
Sent: Thursday, August 05, 2010 2:43 PM
To: fop-dev@xmlgraphics.apache.org; fop-users@xmlgraphics.apache.org
Subject: Re: XSL Page Variable

Eric Douglas wrote:
> If I'm understanding you correctly I think this could work.  I realize

> it's for FOP development and it may not be an FOP issue, but it's not 
> a pure XSLT issue.  The XSLT handles HTML style formatting.
> The FOP is the paging formatter.  This is a page issue.  As you say 
> try "2 passes" I'm thinking I just need to separate the tags, that I'm

> trying to break on PAGE_DATA which triggers the new page call to the 
> simple-page-master, then I'm trying to find the page layout data under

> the PAGE_DATA.  I should be able to get the page layout data before I 
> find the PAGE_DATA tag to start the new pages..

If you know what your FO markup should look like, and you don't know how
to make XSLT do that, ask on the XSL list.[1]

If you don't know what FO markup to make, you can ask on fop-users (not
fop-dev), but please focus on the FO markup itself, and leave the XSLT
out of it.

It looks here like you want to make multiple page-masters and multiple
page-sequences, since you want each page sequcne to have different
geometry.

Please follow-up to either fop-users or xsl-list, but not fop-dev.

~Chris

[1] <URL: http://www.mulberrytech.com/xsl/xsl-list/ >
--
Chris Maden, text nerd  <URL: http://crism.maden.org/ > "I like being
free, and that makes me an idiot, I suppose."
  - Stan Rogers, "The Idiot"
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319

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


Re: XSL Page Variable

Posted by "Christopher R. Maden" <cr...@maden.org>.
Eric Douglas wrote:
> If I'm understanding you correctly I think this could work.  I
> realize it's for FOP development and it may not be an FOP issue, but
> it's not a pure XSLT issue.  The XSLT handles HTML style formatting.
> The FOP is the paging formatter.  This is a page issue.  As you say
> try "2 passes" I'm thinking I just need to separate the tags, that
> I'm trying to break on PAGE_DATA which triggers the new page call to
> the simple-page-master, then I'm trying to find the page layout data
> under the PAGE_DATA.  I should be able to get the page layout data
> before I find the PAGE_DATA tag to start the new pages..

If you know what your FO markup should look like, and you don’t know how
to make XSLT do that, ask on the XSL list.[1]

If you don’t know what FO markup to make, you can ask on fop-users (not
fop-dev), but please focus on the FO markup itself, and leave the XSLT
out of it.

It looks here like you want to make multiple page-masters and multiple
page-sequences, since you want each page sequcne to have different geometry.

Please follow-up to either fop-users or xsl-list, but not fop-dev.

~Chris

[1] <URL: http://www.mulberrytech.com/xsl/xsl-list/ >
-- 
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
“I like being free, and that makes me an idiot, I suppose.”
  — Stan Rogers, “The Idiot”
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319

Re: XSL Page Variable

Posted by "Christopher R. Maden" <cr...@maden.org>.
Eric Douglas wrote:
> If I'm understanding you correctly I think this could work.  I
> realize it's for FOP development and it may not be an FOP issue, but
> it's not a pure XSLT issue.  The XSLT handles HTML style formatting.
> The FOP is the paging formatter.  This is a page issue.  As you say
> try "2 passes" I'm thinking I just need to separate the tags, that
> I'm trying to break on PAGE_DATA which triggers the new page call to
> the simple-page-master, then I'm trying to find the page layout data
> under the PAGE_DATA.  I should be able to get the page layout data
> before I find the PAGE_DATA tag to start the new pages..

If you know what your FO markup should look like, and you don’t know how
to make XSLT do that, ask on the XSL list.[1]

If you don’t know what FO markup to make, you can ask on fop-users (not
fop-dev), but please focus on the FO markup itself, and leave the XSLT
out of it.

It looks here like you want to make multiple page-masters and multiple
page-sequences, since you want each page sequcne to have different geometry.

Please follow-up to either fop-users or xsl-list, but not fop-dev.

~Chris

[1] <URL: http://www.mulberrytech.com/xsl/xsl-list/ >
-- 
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
“I like being free, and that makes me an idiot, I suppose.”
  — Stan Rogers, “The Idiot”
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319

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


RE: XSL Page Variable

Posted by Eric Douglas <ed...@blockhouse.com>.
Hi Pascal,
 
If I'm understanding you correctly I think this could work.  I realize it's for FOP development and it may not be an FOP issue, but it's not a pure XSLT issue.  The XSLT handles HTML style formatting.  The FOP is the paging formatter.  This is a page issue.  As you say try "2 passes" I'm thinking I just need to separate the tags, that I'm trying to break on PAGE_DATA which triggers the new page call to the simple-page-master, then I'm trying to find the page layout data under the PAGE_DATA.  I should be able to get the page layout data before I find the PAGE_DATA tag to start the new pages..

________________________________

From: Pascal Sancho [mailto:pascal.sancho@takoma.fr] 
Sent: Thursday, August 05, 2010 8:52 AM
To: fop-dev@xmlgraphics.apache.org
Subject: Re: XSL Page Variable


Hi Eric,

this list is about FOP development, not XSLT or XSL-FO questions.
That said:
 - all pages features are nested in the fo:root/fo:layout-master-set element,
 - while content is nested in fo:root/fo:page-sequence.

Therefore you should process your XML in a 2 passes XSLT:
 - 1 template for page masters,
 - 1 template for content.

Pascal


Le 05/08/2010 14:26, Eric Douglas a écrit : 

	If the shell of my XSL looks like this: 
	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format <http://www.google.com/url?sa=D&q=http://www.w3.org/1999/XSL/Format&usg=AFQjCNHZhPMfx2p6D5n2w5qLURB5k932Cw> ">
	<fo:layout-master-set>
	<fo:simple-page-master>
	<xsl:attribute name="master-name">STANDARD_PAGE</xsl:attribute>
	<xsl:attribute name="margin-bottom"><xsl:value-of
	select="PAGE_DATA/MARGIN_BOTTOM"/></xsl:attribute>
	<fo:region-body>
	</fo:region-body>
	</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence>
	<xsl:attribute name="master-reference">STANDARD_PAGE</xsl:attribute>
	<fo:flow>
	<xsl:attribute name="flow-name">xsl-region-body</xsl:attribute>
	<xsl:for-each select="PAGE_DATA">
	<fo:block>
	<xsl:attribute name="break-before">page</xsl:attribute>
	<xsl:for-each select="*">
	...
	</xsl:for-each>
	</fo:block>
	</xsl:for-each>
	</fo:flow>
	</fo:page-sequence>
	</fo:root> 
	So I have all my data grouped by what to print on each page, under a
	PAGE_DATA tag in the XML. Now I'm trying to put a tag under the
	PAGE_DATA tag to specify different attributes for each page, such as
	the margin-bottom mentioned here. As it is written here, it is using
	the value of the MARGIN_BOTTOM tag for the margin-bottom attribute,
	but it's only taking the last tag in the XML and applying it to all
	pages. How do I change the attributes for each page?
	Is there a place where I can set a variable from the XML tag value
	which can be processed after the for-each statement and before the
	page attributes? 



Re: XSL Page Variable

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi Eric,

this list is about FOP development, not XSLT or XSL-FO questions.
That said:
 - all pages features are nested in the fo:root/fo:layout-master-set
element,
 - while content is nested in fo:root/fo:page-sequence.

Therefore you should process your XML in a 2 passes XSLT:
 - 1 template for page masters,
 - 1 template for content.

Pascal


Le 05/08/2010 14:26, Eric Douglas a écrit :
>
> If the shell of my XSL looks like this:
> <fo:root xmlns:fo="_http://www.w3.org/1999/XSL/Format_
> <http://www.google.com/url?sa=D&q=http://www.w3.org/1999/XSL/Format&usg=AFQjCNHZhPMfx2p6D5n2w5qLURB5k932Cw>">
> <fo:layout-master-set>
> <fo:simple-page-master>
> <xsl:attribute name="master-name">STANDARD_PAGE</xsl:attribute>
> <xsl:attribute name="margin-bottom"><xsl:value-of
> select="PAGE_DATA/MARGIN_BOTTOM"/></xsl:attribute>
> <fo:region-body>
> </fo:region-body>
> </fo:simple-page-master>
> </fo:layout-master-set>
> <fo:page-sequence>
> <xsl:attribute name="master-reference">STANDARD_PAGE</xsl:attribute>
> <fo:flow>
> <xsl:attribute name="flow-name">xsl-region-body</xsl:attribute>
> <xsl:for-each select="PAGE_DATA">
> <fo:block>
> <xsl:attribute name="break-before">page</xsl:attribute>
> <xsl:for-each select="*">
> ...
> </xsl:for-each>
> </fo:block>
> </xsl:for-each>
> </fo:flow>
> </fo:page-sequence>
> </fo:root>
> So I have all my data grouped by what to print on each page, under a
> PAGE_DATA tag in the XML. Now I'm trying to put a tag under the
> PAGE_DATA tag to specify different attributes for each page, such as
> the margin-bottom mentioned here. As it is written here, it is using
> the value of the MARGIN_BOTTOM tag for the margin-bottom attribute,
> but it's only taking the last tag in the XML and applying it to all
> pages. How do I change the attributes for each page?
> Is there a place where I can set a variable from the XML tag value
> which can be processed after the for-each statement and before the
> page attributes?
>