![]() |
xsl:fo |
1. Creating template to handle "green-bar" effect on multiple nodes (i.e. Detail Lines and Miscellaneous charges)
2. Creating template to handle different page footer effect on different nodes (i.e. Detail Lines and Miscellaneous charges)
3. Putting the style information in its own xsl file and attaching the style.xsl and templates.xsl to your document's xsl
4. Putting document's detail columns in templates.xsl for pre-printed form look
5. Inserting WYSIWYG Comments
1. Creating template to handle "green-bar" effect on multiple nodes (i.e. Detail Lines and Miscellaneous charges)
In templates.xsl create the following template:
<xsl:template match="dc:x" mode="green-bar">
<xsl:param name="pos"/>
<xsl:if test="$pos mod 2 != 0">
<xsl:attribute name="background-color"><xsl:value-of select="/dc:x/dc:Style/dc:Green_Bar"/></xsl:attribute>
</xsl:if>
<xsl:if test="$pos mod 2 = 0">
<xsl:attribute name="background-color">#FFFFFF</xsl:attribute>
</xsl:if>
</xsl:template>In your document's xsl file (packing-list.xsl, invoice.xsl, etc) you can call this template by:
<fo:table-body>
<xsl:for-each select="dc:Detail_Line"> <!-- [DETAIL LINES] -->
<fo:table-row keep-together="always">
<xsl:apply-templates select="/dc:x" mode="green-bar">
<xsl:with-param name="pos" select="position()"/>
</xsl:apply-templates>
<xsl:apply-templates select="/dc:x" mode="pack-total-set">
<xsl:with-param name="pos" select="position()"/>
<xsl:with-param name="last" select="last()"/>
</xsl:apply-templates>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-detail" text-align="right">
<fo:block >
...
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>When you want to continue the green-bar effect through the miscellaneous charges:
<!-- this is to get the count of the # of detail lines -->
<xsl:variable name="detail_count" select="count(/dc:x/dc:Detail_Line)" /><xsl:for-each select="dc:Footer/dc:Miscellaneous">
<fo:table-row>
<xsl:apply-templates select="/dc:x" mode="green-bar">
<xsl:with-param name="pos" select="position() + $detail_count"/>
</xsl:apply-templates>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-detail">
<fo:block>
...
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
2. Creating template to handle different page footer effect on different nodes (i.e. Detail Lines and Miscellaneous charges):
In templates.xsl, create a template that creates the two different footers. This example simply puts a "Continued" at the bottom of every page except the last page:
<xsl:template match="dc:x" mode="pack-total-set">
<xsl:param name="pos"/>
<xsl:param name="last"/><xsl:choose>
<xsl:when test="$pos = $last">
<fo:marker marker-class-name="po_total_marker">
<!--This is the footer on the last page -->
<fo:block font-weight="bold" text-align="right">
 
</fo:block>
</fo:marker>
</xsl:when>
<xsl:otherwise>
<fo:marker marker-class-name="po_total_marker">
<!--This is the footer on every page except the last -->
<fo:block font-weight="bold" text-align="right">
Continued...
</fo:block>
</fo:marker>
</xsl:otherwise>
</xsl:choose>
</xsl:template>In your document's xsl, you apply this template in your first table cell of the xsl:for-each statement:
<fo:table-body>
<xsl:for-each select="dc:Detail_Line"> <!-- [DETAIL LINES] -->
<fo:table-row keep-together="always">
<xsl:apply-templates select="/dc:x" mode="green-bar">
<xsl:with-param name="pos" select="position()"/>
</xsl:apply-templates><fo:table-cell xsl:use-attribute-sets="table-cell-col-detail" text-align="right">
<fo:block >
<xsl:apply-templates select="/dc:x" mode="pack-total-set">
<xsl:with-param name="pos" select="position()"/>
<xsl:with-param name="last" select="last()"/>
</xsl:apply-templates>
...
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
...
</xsl:table-body>
3. Putting the style information in its own xsl file and attaching the style.xsl and templates.xsl to your document's xsl.
In a file called style.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:dc="http://www.ci-inc.com/namespace" ><xsl:attribute-set name="table-cell">
<xsl:attribute name="font-family">Helvetica</xsl:attribute>
<xsl:attribute name="font-size">10pt</xsl:attribute>
<xsl:attribute name="text-align">start</xsl:attribute>
<xsl:attribute name="display-align">before</xsl:attribute>
<xsl:attribute name="padding-start">3pt</xsl:attribute>
<xsl:attribute name="padding-end">3pt</xsl:attribute>
<xsl:attribute name="padding-before">2pt</xsl:attribute>
<xsl:attribute name="padding-after">2pt</xsl:attribute>
<xsl:attribute name="border-style">solid</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-white" use-attribute-sets="table-cell">
<xsl:attribute name="border-width">0pt</xsl:attribute>
<xsl:attribute name="border-color">#FFFFFF</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-hdg" use-attribute-sets="table-cell">
<xsl:attribute name="border-width">1pt</xsl:attribute>
<xsl:attribute name="border-color">#000000</xsl:attribute>
<xsl:attribute name="background-color"><xsl:value-of select="/dc:x/dc:Style/dc:Green_Bar"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-hdg-white" use-attribute-sets="table-cell">
<xsl:attribute name="border-color">#FFFFFF</xsl:attribute>
<xsl:attribute name="background-color"><xsl:value-of select="/dc:x/dc:Style/dc:Green_Bar"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-hdg-data" use-attribute-sets="table-cell-hdg">
<xsl:attribute name="border-color">#000000</xsl:attribute>
<xsl:attribute name="background-color">#FFFFFF</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-col-hdg" use-attribute-sets="table-cell-hdg">
<xsl:attribute name="border-color">#000000</xsl:attribute>
<xsl:attribute name="background-color"><xsl:value-of select="/dc:x/dc:Style/dc:Column_Heading"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-col-data" use-attribute-sets="table-cell">
<xsl:attribute name="border-width">1pt</xsl:attribute>
<xsl:attribute name="border-bottom-color">#000000</xsl:attribute>
<xsl:attribute name="border-left-color">#000000</xsl:attribute>
<xsl:attribute name="border-right-color">#000000</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="table-cell-col-detail" use-attribute-sets="table-cell">
<xsl:attribute name="border-width">1pt</xsl:attribute>
<xsl:attribute name="border-top-color"><xsl:value-of select="/dc:x/dc:Style/dc:Line_Break"/></xsl:attribute>
<xsl:attribute name="border-bottom-color"><xsl:value-of select="/dc:x/dc:Style/dc:Line_Break"/></xsl:attribute>
<xsl:attribute name="border-left-color">#000000</xsl:attribute>
<xsl:attribute name="border-right-color">#000000</xsl:attribute>
</xsl:attribute-set></xsl:stylesheet>
In your document 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" xmlns:dc="http://www.ci-inc.com/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">
<xsl:import href="templates.xsl"/>
<xsl:include href="style.xsl "/>
...
4. Putting document's detail columns in templates.xsl for pre-printed form look
First, in templates.xsl, put the column layout in a template:
<xsl:template match="dc:x" mode="pack-columns">
<fo:table-column column-width="1in" />
<fo:table-column column-width=".45in" />
<fo:table-column column-width="1.35in" />
<fo:table-column column-width="5.1in" />
</xsl:template>In your document, you can call up this template in your region-before area:
<fo:table table-layout="fixed" space-before.optimum="0pt" space-after.optimum="0pt">
<!-- initializes detail column headings : BEGIN -->
<xsl:apply-templates select="dc:x" mode="pack-columns"/>
<!-- initializes detail column headings : END -->
<fo:table-header>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row height="5.12in"> <!--- height of preprinted form area -->
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table-cell-col-data">
<fo:block> </fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>To use the template in your region-body area:
<xsl:for-each select="dc:x"> <!-- [REPORT NAME] as seen in XML -->
<fo:table table-layout="fixed" space-before.optimum="0pt" space-after.optimum="0pt">
<!-- initializes detail column headings : BEGIN -->
<xsl:apply-templates select="/dc:x" mode="pack-columns"/>
<!-- initializes detail column headings : END -->
<fo:table-header>
<xsl:call-template name="WYSIWYG_Comment">
<xsl:with-param name="comment" select="dc:Line_Comment_WYSIWYG/dc:Comment_Line"/>
</xsl:call-template>