replaced unicode literal with hex escape sequence so it loads with the regular ascii...
[TestXSLT.git] / Distribution / readme2fo.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Id$ -->
3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
4 <!-- Need to instruct the XSLT processor to use XML output rules.
5      See http://www.w3.org/TR/xslt#output for more details
6 -->
7         <xsl:output method="xml" indent="yes" encoding="UTF-8" />
8         <xsl:param name="version" />
9
10
11
12         <!-- This template matches the root element of the readme document and emits the page
13          master definitions -->
14         <xsl:template match='readme'>
15
16                 <fo:root>
17
18
19
20                         <!-- We are producing A4 pages -->
21                         <fo:layout-master-set>
22                                 <fo:simple-page-master
23                                         master-name="main-a4"
24                                         page-height="297mm" page-width="210mm"
25                                         margin-top="20mm" margin-right="30mm" margin-bottom="10mm" margin-left="20mm"
26                                 >
27                                         <fo:region-before extent="20mm"/>
28                                         <fo:region-body margin-top="0mm" margin-bottom="20mm"/>
29                                         <fo:region-after extent="10mm"/>
30                                 </fo:simple-page-master>
31
32                                 <fo:page-sequence-master master-name="sequence">
33                                         <fo:single-page-master-reference master-reference="main-a4"/>
34                                 </fo:page-sequence-master>
35                                 
36                         </fo:layout-master-set>
37
38
39                         <!-- define a master page sequence. Our sequence is simple and only has
40                              one kind of page for the entire document. -->
41                         <fo:page-sequence master-reference="main-a4">
42
43                                 
44                                 <!-- This fo:static-content element which we are putting into the "after" section
45                                      will create a small footer with the document title and the page number at the
46                                      bottom of each page -->
47                                 <fo:static-content flow-name="xsl-region-after">
48                                 <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>
49                                 </fo:static-content>
50         
51
52
53                                 <!-- This is the main and only flow which produces
54                                      content for the pages -->
55                                 <fo:flow flow-name="xsl-region-body">
56                                 <xsl:apply-templates/>
57                                 <fo:block padding-top="40mm"><fo:external-graphic src="file:///Users/liyanage/cvs/entropy/TestXSLT/TestXSLT-Icon.png"/></fo:block>
58                                 </fo:flow>
59
60                         </fo:page-sequence>
61
62                 </fo:root>
63
64         </xsl:template>
65
66
67
68
69
70
71
72
73         <!-- Following are all templates which produce XSL-FO layout elements,
74              usually this means fo:block elements with various attributes -->
75
76
77         <!-- The title is in a gray box -->
78         <xsl:template match='title'>
79                 <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">
80                         <xsl:apply-templates/> v<xsl:value-of select="$version"/>
81                 </fo:block>
82         </xsl:template>
83
84
85
86
87
88
89
90         <!-- description, requirements and history all look the same because they
91              are all introduce a top-level section -->
92         <xsl:template match='description'>
93                 <fo:block padding-top="8mm" font-family="Helvetica"  font-weight="bold" font-size="18pt">Description</fo:block>
94
95                 <xsl:call-template name="sectionrule"/>
96                 <fo:block margin-left="15mm"><xsl:apply-templates/></fo:block>
97
98         </xsl:template>
99
100
101         <xsl:template match='requirements'>
102                 <fo:block padding-top="8mm" font-family="Helvetica"  font-weight="bold" font-size="18pt">Requirements</fo:block>
103
104                 <xsl:call-template name="sectionrule"/>
105                 <fo:block margin-left="15mm"><xsl:call-template name="para"/></fo:block>
106
107         </xsl:template>
108
109
110         <xsl:template match='history'>
111                 <fo:block padding-top="8mm" font-family="Helvetica"  font-weight="bold" font-size="18pt">History</fo:block>
112
113                 <xsl:call-template name="sectionrule"/>
114                 <xsl:apply-templates/>
115         </xsl:template>
116
117
118
119
120
121
122
123         <!-- This produces a list-block item for history entries -->
124         <xsl:template match='entry'>
125                 <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>
126
127                 <xsl:call-template name="entryrule"/>
128                 <fo:list-block margin-left="15mm"><xsl:apply-templates select="item"/></fo:list-block>
129         </xsl:template>
130
131
132         <xsl:template match='item'>
133
134                 <fo:list-item font-size="12pt" line-height="15pt">
135                         <fo:list-item-label><fo:block padding-top="0.5mm" font-family="ZapfDingbats">&#x2794;</fo:block></fo:list-item-label>
136                         <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>
137                 </fo:list-item>
138         </xsl:template>
139
140
141
142
143         <!-- A 1pt-wide horizontal rule for the section headings -->
144         <xsl:template name='sectionrule'>
145                 <fo:block padding-top="-3mm"><fo:leader leader-length="100%" leader-pattern="rule" rule-style="solid" rule-thickness="1pt" color="black"/></fo:block>
146         </xsl:template>
147
148
149         <!-- A 1pw-wide dotted horizontal rule for history entry subheadings -->
150         <xsl:template name='entryrule'>
151                 <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>
152         </xsl:template>
153
154
155         <!-- Our regular paragraphs in the description section -->
156         <xsl:template match='para' name='para'>
157                 <fo:block padding-top="2mm" font-size="12pt" font-family="Times" line-height="15pt"><xsl:apply-templates/></fo:block>
158
159         </xsl:template>
160
161
162         <!-- Make real, clickable URLs out of url elements -->
163         <xsl:template match='url'>
164 <fo:basic-link external-destination="{.}"><fo:inline color="blue"><xsl:apply-templates/></fo:inline></fo:basic-link>    </xsl:template>
165
166
167         <!-- The same for email, put make them mailto: URLs -->
168         <xsl:template match='email'>
169
170                 <fo:basic-link external-destination="mailto:{.}?subject=TestXSLT-Readme-PDF"><fo:inline color="blue"><xsl:apply-templates/></fo:inline></fo:basic-link>
171         </xsl:template>
172
173
174         <!-- Document authorship information -->
175         <xsl:template match='author'>
176
177                 <fo:block padding-top="5mm" font-size="12pt" font-family="Times" font-weight="bold" font-style="italic"><xsl:apply-templates/></fo:block>
178
179         </xsl:template>
180
181
182
183
184         <!-- The templates above should catch all content, we do not want
185              anything to fall through. If something still does, we will paint
186              a red border around it here so it stands out and we can fix the problem -->
187         <xsl:template match='*'>
188                 <fo:block border-style="solid" border-color="red" border-width="0.5pt" margin-top="10mm" font-size="10pt" font-family="Helvetica" line-height="12pt">
189                 <xsl:apply-templates/>
190                 </fo:block>
191         </xsl:template>
192
193
194 </xsl:stylesheet>