- Joined
- Sep 16, 2011
- Messages
- 2
- Reaction score
- 0
Hi,
I have an XSL I use for identifying the XML - e.g. takes the XML and transforms it into another XML. This works as expected when it's XSLT.
However I need to make this work in the same work but using XSL:FO so that it can be made pretty for print and outputted as a PDF.
I am sure this should be simple, and I am missing something obvious.
Any help would be much appreciated,
My 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">
<xslutput method="xml" version="1.0" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<fo:root font-size="9pt" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="all" page-height="279.4mm" page-width="215.9mm" margin-top="5mm" margin-bottom="5mm" margin-left="5mm" margin-right="5mm">
<fo:region-body margin-top="40mm" margin-bottom="45mm"/>
<fo:region-before extent="40mm"/>
<fo:region-after extent="45mm"/>
</fo:simple-page-master>
<foage-sequence-master master-name="pagesequences" initial-page-number="1" force-page-count="no-force">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference odd-or-even="odd" master-reference="all"/>
<fo:conditional-page-master-reference odd-or-even="even" master-reference="all"/>
</fo:repeatable-page-master-alternatives>
</foage-sequence-master>
</fo:layout-master-set>
<foage-sequence master-reference="pagesequences">
<fo:static-content id="page1-static-before" flow-name="xsl-region-before">
<fo:table>
<fo:table-column column-width="200mm"/>
<fo:table-body>
<fo:table-row text-align="center">
<fo:table-cell>
<fo:block>
This is a copy the generated XML
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" color="black">
<fo:block>
<xsl:apply-templates select="/ | node()"/>
</fo:block>
</fo:flow>
</foage-sequence>
</fo:root>
</xsl:template>
<xsl:template match="/ | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*" >
<xsl:element name="attribute">
<xsl:attribute name="name">
<xsl:value-of select="local-name()" />
</xsl:attribute>
<xsl:value-of select="." />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
SAMPLE XML:
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<header>
<test>This is test</test>
</header>
</xml>
I have an XSL I use for identifying the XML - e.g. takes the XML and transforms it into another XML. This works as expected when it's XSLT.
However I need to make this work in the same work but using XSL:FO so that it can be made pretty for print and outputted as a PDF.
I am sure this should be simple, and I am missing something obvious.
Any help would be much appreciated,
My 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">
<xslutput method="xml" version="1.0" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<fo:root font-size="9pt" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="all" page-height="279.4mm" page-width="215.9mm" margin-top="5mm" margin-bottom="5mm" margin-left="5mm" margin-right="5mm">
<fo:region-body margin-top="40mm" margin-bottom="45mm"/>
<fo:region-before extent="40mm"/>
<fo:region-after extent="45mm"/>
</fo:simple-page-master>
<foage-sequence-master master-name="pagesequences" initial-page-number="1" force-page-count="no-force">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference odd-or-even="odd" master-reference="all"/>
<fo:conditional-page-master-reference odd-or-even="even" master-reference="all"/>
</fo:repeatable-page-master-alternatives>
</foage-sequence-master>
</fo:layout-master-set>
<foage-sequence master-reference="pagesequences">
<fo:static-content id="page1-static-before" flow-name="xsl-region-before">
<fo:table>
<fo:table-column column-width="200mm"/>
<fo:table-body>
<fo:table-row text-align="center">
<fo:table-cell>
<fo:block>
This is a copy the generated XML
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" color="black">
<fo:block>
<xsl:apply-templates select="/ | node()"/>
</fo:block>
</fo:flow>
</foage-sequence>
</fo:root>
</xsl:template>
<xsl:template match="/ | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*" >
<xsl:element name="attribute">
<xsl:attribute name="name">
<xsl:value-of select="local-name()" />
</xsl:attribute>
<xsl:value-of select="." />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
SAMPLE XML:
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<header>
<test>This is test</test>
</header>
</xml>