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

Re: Different (body) layout on odd and even pages in

Subject: Re: Different (body) layout on odd and even pages in XSL-FO?
From: "Christian Rosberg" <christian.rosberg@xxxxxxxxxxxxxxxxxx>
Date: Wed, 15 Dec 2004 11:30:17 +0100
xsl odd even
Hi again,

I think you need to post your stylesheet so that people out here can analyse and point the the problem.

here I have some simplified code for those interested in the problem. Using the code below I get the products listed twice, at first - all products with images to the left and then all product again with the images to the right (which make sense since I call the apply-template twice, using different modes). Is there any way that I can split upp the flow making half of the products "left-aligned" (odd pages) and the other half "right-aligned" (even pages).


A nice feature (not) in this code is also that it only renders odd-headers and on the last page it renders double odd headers??

Regards Christian


--------- products.xml ------------


<?xml version="1.0" encoding="UTF-8"?>
<products>
<product>
 <name>Product 1</name>
 <description>Description</description>
 <image>image1.jpg</image>
</product>
<product>
 <name>Product 2</name>
 <description>Description</description>
 <image>image2.jpg</image>
</product>
...
...
...
</products>


--------- products.xsl ------------


<?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:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>

<xsl:template match="/">
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- Master-set -->
<fo:layout-master-set>
<fo:page-sequence-master master-name="products">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="products-odd" odd-or-even="odd"/>
<fo:conditional-page-master-reference master-reference="products-even" odd-or-even="even"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
<fo:simple-page-master master-name="products-odd">
<fo:region-before extent='20mm' region-name="header-odd"/>
<fo:region-body region-name="body-odd" margin="20mm"/>
<fo:region-after extent='20mm' region-name="footer-odd"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="products-even">
<fo:region-before extent='20mm' region-name="header-even"/>
<fo:region-body region-name="body-even" margin="20mm"/>
<fo:region-after extent='20mm' region-name="footer-even"/>
</fo:simple-page-master>
</fo:layout-master-set>


  <!-- Products -->
  <fo:page-sequence master-reference="products">
   <fo:static-content flow-name="header-odd">
    <fo:block text-align="left">
     <xsl:text>Header odd</xsl:text>
    </fo:block>
   </fo:static-content>
   <fo:static-content flow-name="header-even">
    <fo:block text-align="right">
     <xsl:text>Header even</xsl:text>
    </fo:block>
   </fo:static-content>
   <fo:static-content flow-name="footer-odd">
    <fo:block text-align="left">
     <xsl:text>Footer odd</xsl:text>
    </fo:block>
   </fo:static-content>
   <fo:static-content flow-name="footer-even">
    <fo:block text-align="right">
     <xsl:text>Footer even</xsl:text>
    </fo:block>
   </fo:static-content>
   <fo:flow flow-name="body-odd">
    <fo:block>
     <xsl:apply-templates select="products/product" mode="odd"/>
    </fo:block>
   </fo:flow>
   <fo:flow flow-name="body-even">
    <fo:block>
     <xsl:apply-templates select="products/product" mode="even"/>
    </fo:block>
   </fo:flow>
  </fo:page-sequence>

 </fo:root>
</xsl:template>

<xsl:template match="products/product" mode="odd">
<fo:block margin-top="20mm">
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell width="30%">
<fo:block>
<fo:external-graphic src="image" content-width="30mm" content-height="30mm"/>
</fo:block>
</fo:table-cell>
<fo:table-cell width="70%">
<fo:block>
<xsl:value-of select="concat(name, ' - ', description)" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>


<xsl:template match="products/product" mode="even">
<fo:block margin-top="20mm">
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell width="70%">
<fo:block>
<xsl:value-of select="concat(name, ' - ', description)" />
</fo:block>
</fo:table-cell>
<fo:table-cell width="30%">
<fo:block>
<fo:external-graphic src="image" content-width="30mm" content-height="30mm"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>


</xsl:stylesheet>

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.