90 likes | 176 Views
Expanding towards multichannel publishing. .xsl. .xsl. .html. .pdf. .xml. Generating the Pages.
E N D
Expanding towards multichannel publishing .xsl .xsl .html .pdf .xml
Generating the Pages One of the problems is that, unlike the production of an HTML document from an XML source using XSLT, the processing of the children of the root elements is not a simple xsl:apply-templates from within a root element. Much more initial output is required in order to enable the formatter to generate the pages. Let's look at the processing necessary to get from your XML document to a PDF printable document. First, the XML must be fed to an XSLT processor with an appropriate stylesheet in order to produce another XML document which uses the XSL-FO namespace and is intended for an XSL-FO formatter. The second stage is to feed the output of the first stage to the XSL-FO formatter, which can then produce the end product: a printable document, styled for visual presentation.
Generating Process XSLT Style sheet XML document XSLT Engine XS-FO Document XS-FO Formatter Printable document
products.xml <?xml version="1.0" ?> <products> <product><name>Disket</name><price currency="EUR">1.50</price></product> <product><name>Cleaner</name><price currency="EUR">2.50</price></product> <product><name>Paper</name><price currency="EUR">3.50</price></product> <product><name>Pen</name><price currency="EUR">9.50</price></product> <product><name>Balm</name><price currency="EUR">2.20</price></product> <product><name>Mouse</name><price currency="EUR">2.10</price></product> <product><name>Flower</name><price currency="EUR">6.50</price></product> <product><name>Phone</name><price currency="EUR">8.50</price></product> <product><name>Shoe</name><price currency="EUR">1.30</price></product> <product><name>Hat</name><price currency="USD">1.10</price></product> </products>
<xsl:template match="/"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!-- (First) Page setup --> <fo:layout-master-set> <fo:simple-page-master master-name="first" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="1.5cm" margin-right="1.5cm"> <fo:region-before extent="3cm"/> <fo:region-body margin-top="3cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> products.xslPage layout
<!-- Page static content --> <fo:page-sequence master-reference="first"> <fo:flow flow-name="xsl-region-body"> <fo:block font-size="10pt" font-family="sans-serif" line-height="12pt"> These products are in the shop. Some other goods are available within two days delivery ... </fo:block> <!-- Start of the table --> <fo:table border-style="solid" border-color="black"> <fo:table-column column-width="4cm"/> <fo:table-body font-size="12pt"> <fo:table-row line-height="18pt"> <fo:table-cell> <fo:block text-align="center">** Product name **</fo:block> </fo:table-cell> </fo:table-row> <xsl:apply-templates/> </fo:table-body> </fo:table> </fo:flow> </fo:page-sequence> </fo:root> products.xsl page sequence
Products.xsl table elements <!--Print xml data flow to the table --> <xsl:template match="products"> <xsl:for-each select="product"> <fo:table-row line-height="14pt" > <fo:table-cell border-style="solid" border-color="blue"> <fo:block text-align="center"><xsl:value-of select="name"/></fo:block> </fo:table-cell> </fo:table-row> </xsl:for-each> </xsl:template> </xsl:stylesheet>
XSL-FO Documenttemp.fo <?xml version="1.0" encoding="UTF-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-set><fo:simple-page-master margin-right="1.5cm" margin-left="1.5cm" margin-bottom="2cm" margin-top="1cm" page-width="21cm" page-height="29.7cm" master-name="first"><fo:region-before extent="3cm"/><fo:region-body margin-top="3cm"/><fo:region-after extent="1.5cm"/></fo:simple-page-master></fo:layout-master-set><fo:page-sequence master-reference="first"><fo:flow flow-name="xsl-region-body"><fo:block line-height="12pt" font-family="sans-serif" font-size="10pt"> These products are in the shop. Some other goods are available within two days delivery time - please ask the boss Kake to get the list ordered goods. </fo:block><fo:table border-color="black" border-style="solid"><fo:table-column column-width="4cm"/><fo:table-body font-size="12pt"><fo:table-row line-height="18pt"><fo:table-cell><fo:block text-align="center">** Product name **</fo:block></fo:table-cell></fo:table-row><fo:table-row line-height="14pt"><fo:table-cell border-color="blue" border-style="solid"><fo:block text-align="center">Disket</fo:block></fo:table-cell></fo:table-row><fo:table-row line-height="14pt"><fo:table-cell border-color="blue" border-style="solid"><fo:block text-align="center">Cleaner</fo:block></fo:table-cell></fo:table-row><fo:table-row line- …...