|
||||||||
<?xml version="1.0" encoding="utf-8"?>
<bookdata>
<book>
<isbn>978-1592001170</isbn>
<title>Inspired 3D Short Film Production</title>
<author>Jeremy Cantor and Pepe Valencia</author>
<price>31.50</price>
</book>
<book>
<isbn>978-0321316318</isbn>
<title>Digital Lighting and Rendering</title>
<author>Jeremy Birn</author>
<price>34.65</price>
</book>
<book>
<isbn>978-0571202287</isbn>
<title>The Animator's Survival Kit</title>
<author>Richard Williams </author>
<price>19.80</price>
</book>
</bookdata>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="bookdata">
<root>
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body">
</flow>
</page-sequence>
</root>
</xsl:template>
</xsl:stylesheet>[Download examples/tabular/layout1.xsl]
ibex35 -transform bookdata.xml layout1.xsl layout1.fo
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://www.w3.org/1999/XSL/Format">
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body" />
</page-sequence>
</root>[Download examples/tabular/layout1.fo]
ibex35 layout1.fo layout1.pdf
ibex35 -xsl layout1.xsl bookdata.xml layout1.pdf
<table>
<table-body>
<table-row>
<table-cell>
<block/>
</table-cell>
</table-row>
</table-body>
</table>
<table> <table-body> <xsl:apply-templates select="book"/> </table-body> </table>
<xsl:template match="book">
<table-row>
<table-cell>
<block>
<xsl:value-of select="isbn/text()"/>
</block>
</table-cell>
<table-cell>
<block>
<xsl:value-of select="title/text()"/>
</block>
</table-cell>
<table-cell>
<block>
<xsl:value-of select="price/text()"/>
</block>
</table-cell>
</table-row>
</xsl:template><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="bookdata">
<root>
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body">
<table>
<table-body>
<xsl:apply-templates select="book" />
</table-body>
</table>
</flow>
</page-sequence>
</root>
</xsl:template>
<xsl:template match="book">
<table-row>
<table-cell>
<block>
<xsl:value-of select="isbn/text()" />
</block>
</table-cell>
<table-cell>
<block>
<xsl:value-of select="title/text()" />
</block>
</table-cell>
<table-cell>
<block>
<xsl:value-of select="price/text()" />
</block>
</table-cell>
</table-row>
</xsl:template>
</xsl:stylesheet>[Download examples/tabular/layout2.xsl]
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://www.w3.org/1999/XSL/Format">
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body">
<table>
<table-body>
<table-row>
<table-cell>
<block>978-1592001170</block>
</table-cell>
<table-cell>
<block>Inspired 3D Short Film Production</block>
</table-cell>
<table-cell>
<block>31.50</block>
</table-cell>
</table-row>
<table-row>
<table-cell>
<block>978-0321316318</block>
</table-cell>
<table-cell>
<block>Digital Lighting and Rendering</block>
</table-cell>
<table-cell>
<block>34.65</block>
</table-cell>
</table-row>
<table-row>
<table-cell>
<block>978-0571202287</block>
</table-cell>
<table-cell>
<block>The Animator's Survival Kit</block>
</table-cell>
<table-cell>
<block>19.80</block>
</table-cell>
</table-row>
</table-body>
</table>
</flow>
</page-sequence>
</root>[Download examples/tabular/layout2.fo]
We can add cell borders by using the border attribute on each cell. We also want to add some
padding so that there is some spacing between the cell contents and the borders. To do this we change the
stylesheet, adding border and padding attributes to each cell:
<xsl:template match="book">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="isbn/text()"/>
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="title/text()"/>
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>
<xsl:value-of select="price/text()"/>
</block>
</table-cell>
</table-row>
</xsl:template>
<table> <table-column column-number="1" column-width="25%"/> <table-column column-number="2" column-width="60%"/> <table-column column-number="3" column-width="15%"/> <table-body> <xsl:apply-templates select="book"/> </table-body> </table>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="bookdata">
<root>
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body">
<table>
<table-column column-number="1" column-width="25%" />
<table-column column-number="2" column-width="60%" />
<table-column column-number="3" column-width="15%" />
<table-body>
<xsl:apply-templates select="book" />
</table-body>
</table>
</flow>
</page-sequence>
</root>
</xsl:template>
<xsl:template match="book">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="isbn/text()" />
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="title/text()" />
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>
<xsl:value-of select="price/text()" />
</block>
</table-cell>
</table-row>
</xsl:template>
</xsl:stylesheet>[Download examples/tabular/layout4.xsl]
<table>
<table-column column-number="1" column-width="25%"/>
<table-column column-number="2" column-width="60%"/>
<table-column column-number="3" column-width="15%"/>
<table-header font-weight="bold">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>ISBN Number
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>Title
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>Price
</block>
</table-cell>
</table-row>
</table-header>
<table-body>
<xsl:apply-templates select="book"/>
</table-body>
</table><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="bookdata">
<root>
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body">
<table>
<table-column column-number="1" column-width="25%" />
<table-column column-number="2" column-width="60%" />
<table-column column-number="3" column-width="15%" />
<table-header font-weight="bold">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>ISBN Number</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>Title</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>Price</block>
</table-cell>
</table-row>
</table-header>
<table-body>
<xsl:apply-templates select="book" />
</table-body>
</table>
</flow>
</page-sequence>
</root>
</xsl:template>
<xsl:template match="book">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="isbn/text()" />
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="title/text()" />
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>
<xsl:value-of select="price/text()" />
</block>
</table-cell>
</table-row>
</xsl:template>
</xsl:stylesheet>[Download examples/tabular/layout5.xsl]
Repeating headers: repeating the table header after each page break is the default behaviour of Ibex. To
prevent the header being repeated specify table-omit-header-at-break="true" on the table element.
<table>
<table-column column-number="1" column-width="25%"/>
<table-column column-number="2" column-width="60%"/>
<table-column column-number="3" column-width="15%"/>
<table-header font-weight="bold">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>ISBN Number
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>Title
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>Price
</block>
</table-cell>
</table-row>
</table-header>
<table-footer font-weight="bold">
<table-row>
<table-cell number-columns-spanned="2" border="1pt solid black" padding="4pt">
<block>Total Price
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>
<xsl:value-of select="sum(book/price)"/>
</block>
</table-cell>
</table-row>
</table-footer>
<table-body>
<xsl:apply-templates select="book"/>
</table-body>
</table><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="bookdata">
<root>
<layout-master-set>
<simple-page-master master-name="page-layout" page-height="11in" page-width="8in">
<region-body margin="1in" region-name="body" background-color="#dddddd" />
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="page-layout">
<flow flow-name="body">
<table>
<table-column column-number="1" column-width="25%" />
<table-column column-number="2" column-width="60%" />
<table-column column-number="3" column-width="15%" />
<table-header font-weight="bold">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>ISBN Number</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>Title</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>Price</block>
</table-cell>
</table-row>
</table-header>
<table-footer font-weight="bold">
<table-row>
<table-cell number-columns-spanned="2" border="1pt solid black" padding="4pt">
<block>Total Price</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>
<xsl:value-of select="sum(book/price)" />
</block>
</table-cell>
</table-row>
</table-footer>
<table-body>
<xsl:apply-templates select="book" />
</table-body>
</table>
</flow>
</page-sequence>
</root>
</xsl:template>
<xsl:template match="book">
<table-row>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="isbn/text()" />
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt">
<block>
<xsl:value-of select="title/text()" />
</block>
</table-cell>
<table-cell border="1pt solid black" padding="4pt" text-align="right">
<block>
<xsl:value-of select="price/text()" />
</block>
</table-cell>
</table-row>
</xsl:template>
</xsl:stylesheet>[Download examples/tabular/layout6.xsl]
Repeating footers: repeating the table footer before after each page break is the default behaviour of Ibex. To
prevent the footer being repeated specify table-omit-footer-at-break="true" on the table element.
Copyright (c) 2002-2009 Visual Programming Limited