1 <?xml version="1.0" encoding="UTF-8"?>
\r<!-- $Id$ -->
\r<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
\r<!-- Need to instruct the XSLT processor to use XML output rules.
\r See http://www.w3.org/TR/xslt#output for more details
\r-->
\r <xsl:output method="xml" indent="yes" encoding="UTF-8" />
\r <xsl:param name="version" />
\r
4 <!-- This template matches the root element of the readme document and emits the page
6 <xsl:template match='readme'>
\r\r <fo:root>
\r
8 <!-- We are producing A4 pages -->
9 <fo:layout-master-set>
\r <fo:simple-page-master
\r master-name="main-a4"
\r page-height="297mm" page-width="210mm"
\r margin-top="20mm" margin-right="30mm" margin-bottom="10mm" margin-left="20mm"
\r >
\r <fo:region-before extent="20mm"/>
\r <fo:region-body margin-top="0mm" margin-bottom="20mm"/>
\r <fo:region-after extent="10mm"/>
\r </fo:simple-page-master>
\r\r <fo:page-sequence-master master-name="sequence">
\r <fo:single-page-master-reference master-reference="main-a4"/>
\r </fo:page-sequence-master>
\r \r </fo:layout-master-set>
\r\r
10 <!-- define a master page sequence. Our sequence is simple and only has
11 one kind of page for the entire document. -->
12 <fo:page-sequence master-reference="main-a4">
\r
14 <!-- This fo:static-content element which we are putting into the "after" section
15 will create a small footer with the document title and the page number at the
16 bottom of each page -->
\r <fo:static-content flow-name="xsl-region-after">
\r <fo:block font-family="Helvetica" font-style="italic" font-size="9pt" margin-top="10mm" color="#fff" background-color="#000" padding="1mm"><xsl:value-of select="/readme/title"/> v<xsl:value-of select="$version"/> – Page <fo:page-number/></fo:block>
\r </fo:static-content>
\r \r
18 <!-- This is the main and only flow which produces
19 content for the pages -->
20 <fo:flow flow-name="xsl-region-body">
\r <xsl:apply-templates/>
21 <fo:block padding-top="40mm"><fo:external-graphic src="file:///Users/liyanage/cvs/entropy/TestXSLT/TestXSLT-Icon.png"/></fo:block>
22 </fo:flow>
\r\r </fo:page-sequence>
\r\r </fo:root>
\r\r </xsl:template>
\r\r
29 <!-- Following are all templates which produce XSL-FO layout elements,
30 usually this means fo:block elements with various attributes -->
33 <!-- The title is in a gray box -->
34 <xsl:template match='title'>
\r <fo:block border="0.5pt" padding-top="2mm" padding-bottom="0mm" padding-left="2mm" background-color="#eeeeee" border-color="#aaaaaa" border-style="solid" margin-top="10mm" margin-left="0mm" font-size="24pt" font-family="Helvetica" font-weight="bold" line-height="30pt">
\r <xsl:apply-templates/> v<xsl:value-of select="$version"/>
\r </fo:block>
42 <!-- description, requirements and history all look the same because they
43 are all introduce a top-level section -->
44 <xsl:template match='description'>
\r <fo:block padding-top="8mm" font-family="Helvetica" font-weight="bold" font-size="18pt">Description</fo:block>
\r
45 <xsl:call-template name="sectionrule"/>
46 <fo:block margin-left="15mm"><xsl:apply-templates/></fo:block>
\r
48 <xsl:template match='requirements'>
\r <fo:block padding-top="8mm" font-family="Helvetica" font-weight="bold" font-size="18pt">Requirements</fo:block>
\r
49 <xsl:call-template name="sectionrule"/>
50 <fo:block margin-left="15mm"><xsl:call-template name="para"/></fo:block>
\r
52 <xsl:template match='history'>
\r <fo:block padding-top="8mm" font-family="Helvetica" font-weight="bold" font-size="18pt">History</fo:block>
\r
53 <xsl:call-template name="sectionrule"/>
54 <xsl:apply-templates/>
62 <!-- This produces a list-block item for history entries -->
63 <xsl:template match='entry'>
\r <fo:block keep-with-next="always" padding-top="8mm" font-family="Helvetica" font-weight="bold" font-style="italic" font-size="11pt">Version <xsl:value-of select="version"/>, released <xsl:value-of select="date"/></fo:block>
\r
64 <xsl:call-template name="entryrule"/>
65 <fo:list-block margin-left="15mm"><xsl:apply-templates select="item"/></fo:list-block>
68 <xsl:template match='item'>
\r
69 <fo:list-item font-size="12pt" line-height="15pt">
70 <fo:list-item-label><fo:block padding-top="0.5mm" font-family="ZapfDingbats">➔</fo:block></fo:list-item-label>
71 <fo:list-item-body start-indent="body-start() - 3mm"><fo:block padding-top="0.5mm" font-family="Times"><xsl:apply-templates/></fo:block></fo:list-item-body>
77 <!-- A 1pt-wide horizontal rule for the section headings -->
78 <xsl:template name='sectionrule'>
\r <fo:block padding-top="-3mm"><fo:leader leader-length="100%" leader-pattern="rule" rule-style="solid" rule-thickness="1pt" color="black"/></fo:block>
81 <!-- A 1pw-wide dotted horizontal rule for history entry subheadings -->
82 <xsl:template name='entryrule'>
\r <fo:block keep-with-next="always" padding-top="-3mm"><fo:leader leader-length="100%" leader-pattern="rule" rule-style="dotted" rule-thickness="1pt"/></fo:block>
85 <!-- Our regular paragraphs in the description section -->
86 <xsl:template match='para' name='para'>
\r <fo:block padding-top="2mm" font-size="12pt" font-family="Times" line-height="15pt"><xsl:apply-templates/></fo:block>
\r
88 <!-- Make real, clickable URLs out of url elements -->
89 <xsl:template match='url'>
\r<fo:basic-link external-destination="{.}"><fo:inline color="blue"><xsl:apply-templates/></fo:inline></fo:basic-link> </xsl:template>
\r
91 <!-- The same for email, put make them mailto: URLs -->
92 <xsl:template match='email'>
\r
93 <fo:basic-link external-destination="mailto:{.}?subject=TestXSLT-Readme-PDF"><fo:inline color="blue"><xsl:apply-templates/></fo:inline></fo:basic-link>
96 <!-- Document authorship information -->
97 <xsl:template match='author'>
\r
98 <fo:block padding-top="5mm" font-size="12pt" font-family="Times" font-weight="bold" font-style="italic"><xsl:apply-templates/></fo:block>
\r
103 <!-- The templates above should catch all content, we do not want
104 anything to fall through. If something still does, we will paint
105 a red border around it here so it stands out and we can fix the problem -->
106 <xsl:template match='*'>
\r <fo:block border-style="solid" border-color="red" border-width="0.5pt" margin-top="10mm" font-size="10pt" font-family="Helvetica" line-height="12pt">
\r <xsl:apply-templates/>
\r </fo:block>
\r </xsl:template>
\r\r\r</xsl:stylesheet>
\r