Hello,
My knowledge is limited about XML technologies. I am trying creating PDF files from Value Objects(VO). I am following the following way:
1. VO -> XML
2. Create XSL Stylesheet then
3. Use FOP with XML and XSL Stylesheet files to create PDF file.
2. Create XSL Stylesheet then
3. Use FOP with XML and XSL Stylesheet files to create PDF file.
I am having problem with creating XSL Stylesheet. I am trying to create it manually. How can I create XSL Stylesheet? Is there any good tutorial about it?
Now, I want to output two tables. Both categories are found within the same XML source but need to be placed in separate tables. Here is my xsl Stylesheet code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="projectteam">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="16pt" font-weight="bold" space-after="5mm">Project: <xsl:value-of select="projectname"/>
</fo:block>
<fo:block font-size="10pt">
<fo:table>
<fo:table-column column-width="proportional-column-width(3)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(3)" />
<fo:table-header>
<fo:table-row>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block text-align="justify" font-weight="bold">Column 1</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block text-align="justify" font-weight="bold">Column 2</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block text-align="justify" font-weight="bold">Column 3</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="member">
<fo:table-row>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block>
<xsl:value-of select="name"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block>
<xsl:value-of select="function"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block>
<xsl:value-of select="email"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:template match="projectteam">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="16pt" font-weight="bold" space-after="5mm">Project: <xsl:value-of select="projectname"/>
</fo:block>
<fo:block font-size="10pt">
<fo:table>
<fo:table-column column-width="proportional-column-width(3)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(3)" />
<fo:table-header>
<fo:table-row>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block text-align="justify" font-weight="bold">Column 1</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block text-align="justify" font-weight="bold">Column 2</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block text-align="justify" font-weight="bold">Column 3</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="member">
<fo:table-row>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block>
<xsl:value-of select="name"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block>
<xsl:value-of select="function"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 1px" padding="1em" border-collapse="collapse">
<fo:block>
<xsl:value-of select="email"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
Thanks in advance...
Kevin
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
