source: documentation/tags/3.03/manuals/processing/common.xsl@ 14835

Last change on this file since 14835 was 14096, checked in by lh92, 17 years ago

Added the Link template to match the http links in copyright statements

  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xalan/java"
5 xmlns:util="ExternalRef" extension-element-prefixes="util">
6
7 <xsl:template match="Title"><p><b><i><xsl:apply-templates/></i></b></p></xsl:template>
8
9
10 <xsl:template match="Title" mode="Figure">
11 <xsl:param name="no"/>
12 <div style="margin-right:1.7pt;" align="center"><b>Figure&#160;<xsl:value-of select="$no"/>
13 <xsl:if test="SubTitle"><xsl:value-of select="SubTitle"/></xsl:if>&#160;
14 <xsl:apply-templates select="Text"/></b>
15 </div>
16 </xsl:template>
17
18
19 <xsl:template match="Title" mode="Table">
20 <div style="margin-right:1.7pt;" align="center">
21 <b>Table&#160;<xsl:number count="Table[not(@class='hidden')]" level="any"/>&#160;<xsl:apply-templates/></b></div>
22 </xsl:template>
23
24
25 <xsl:template match="NumberedList"><ol><xsl:apply-templates/></ol></xsl:template>
26 <xsl:template match="NumberedItem"><li><xsl:apply-templates/></li></xsl:template>
27
28
29 <xsl:template match="BulletList">
30 <xsl:if test="not(parent::Bullet)">
31 <ul style="list-style-type: disc;"><xsl:for-each select="Bullet"><li><xsl:apply-templates/></li>
32 <xsl:if test="BulletList">
33 <xsl:for-each select="BulletList"><ul style="list-style-type: disc;"><xsl:for-each select="Bullet"><li><xsl:apply-templates/></li></xsl:for-each></ul>
34 </xsl:for-each></xsl:if></xsl:for-each></ul><p/></xsl:if>
35 </xsl:template>
36
37
38 <xsl:template match="Text">
39 <xsl:choose>
40 <xsl:when test="parent::Indented"><p class="indented"><xsl:apply-templates/></p> </xsl:when>
41 <xsl:when test="parent::Title|parent::Footnote"><xsl:apply-templates/></xsl:when>
42 <xsl:when test="not(parent::Version) and not(parent::Date) and not(parent::NumberedItem) and not(parent::Bullet)"><p><xsl:apply-templates/></p></xsl:when>
43 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
44 </xsl:choose>
45 </xsl:template>
46
47
48 <xsl:template match="CodeLine">
49 <xsl:choose>
50 <!-- codeline in figure or table -->
51 <xsl:when test="parent::Figure or parent::th"><div class="codeline_figure"><xsl:apply-templates/></div></xsl:when>
52 <!-- consecutive codelines -->
53 <xsl:when test="name(preceding-sibling::*[position()=1])='CodeLine' or name(following-sibling::*[position()=1])='CodeLine'"><div class="codeline"><xsl:apply-templates/></div></xsl:when>
54 <!-- a single line of code between two text paragraphs -->
55 <xsl:otherwise><div class="codeline_single"><xsl:apply-templates/></div></xsl:otherwise>
56 </xsl:choose>
57 </xsl:template>
58
59
60 <xsl:template match="Figure">
61 <a id="Figure_{@id}"/>
62 <!-- number of current figure = total_number_of_previous_figure - total_number_of_previous_sub_figures-->
63 <xsl:variable name="temp_total_figs"><xsl:number count="Figure" level="any"/></xsl:variable>
64 <xsl:variable name="temp_num_of_sub_figs">
65 <xsl:number count="Figure[Title/SubTitle and substring(translate(@id, '_0123456789', '99999999999'), string-length(@id)-1, string-length(@id))='99']" level="any"/>
66 </xsl:variable>
67 <xsl:variable name="no"><xsl:value-of select="$temp_total_figs - $temp_num_of_sub_figs"/></xsl:variable>
68
69 <p/>
70 <xsl:apply-templates select="Title" mode="Figure"><xsl:with-param name="no" select="$no"/></xsl:apply-templates>
71 <xsl:choose>
72 <xsl:when test="CodeLine">
73 <table class="figure_code" align="center">
74 <xsl:for-each select="*[not(name()='Title')]">
75 <tr>
76 <xsl:if test="parent::Figure[@class='withLineNumber']">
77 <td><div class="linenumber"><xsl:number value="position()" format="1"/>&#160;&#160;</div></td></xsl:if>
78 <td><xsl:apply-templates select="."/></td></tr>
79 </xsl:for-each>
80 </table>
81 </xsl:when>
82 <xsl:when test="File"><div align="center"><xsl:apply-templates select="File"/></div><br/>
83 </xsl:when>
84 </xsl:choose>
85 <br/>
86 </xsl:template>
87
88
89 <xsl:template match="Table">
90 <p/><a id="Table_{@id}"/>
91 <xsl:if test="not(@class='hidden') and not(normalize-space(Title/Text)='')"><xsl:apply-templates select="Title" mode="Table"/></xsl:if>
92 <table cellpadding="2pt" cellspacing="2pt">
93 <xsl:if test="not(@class='hidden')">
94 <xsl:if test="not(../../@class='hidden')"><xsl:attribute name="style">border-collapse:collapse;border:1px solid black;</xsl:attribute></xsl:if>
95 <xsl:attribute name="rules">rows</xsl:attribute><xsl:attribute name="align">center</xsl:attribute>
96 </xsl:if>
97 <xsl:if test="@class='hidden'"><xsl:attribute name="width">90%</xsl:attribute><xsl:attribute name="align">center</xsl:attribute></xsl:if>
98 <xsl:for-each select="TableContent/tr">
99 <tr>
100 <xsl:if test="not(../../@class='hidden')"><xsl:attribute name="style">border-collapse:collapse;border:1px solid black;</xsl:attribute></xsl:if>
101 <xsl:for-each select="th"><td valign="top"><xsl:if test="File"><xsl:attribute name="align">right</xsl:attribute></xsl:if>
102 <xsl:apply-templates select="node()"/></td></xsl:for-each>
103 </tr>
104 </xsl:for-each>
105 </table>
106 <br/>
107 </xsl:template>
108
109
110 <xsl:template match="Section">
111 <a name="Section_{@id}"/><h3><xsl:if test="not(starts-with(../../@id, 'appendix'))">
112 <xsl:number level="multiple" format="1.1" count="//Chapter|//Chapter//Section"/>&#160;</xsl:if>
113 <xsl:apply-templates select="Title/Text"/></h3><xsl:apply-templates select="Content/*"/>
114 </xsl:template>
115
116
117 <xsl:template match="Section" mode="preface">
118 <h3><xsl:apply-templates select="Title/Text"/></h3>
119 <xsl:apply-templates select="Content/*"/>
120 </xsl:template>
121
122
123 <xsl:template match="Subsection">
124 <a name="Subsection_{@id}"/>
125 <h4><xsl:apply-templates select="Title/Text"/></h4>
126 <xsl:apply-templates select="Content/*"/>
127 </xsl:template>
128
129
130 <xsl:template match="Part"><a id="Part_{@id}"/><xsl:apply-templates/></xsl:template>
131 <xsl:template match="Comment"><xsl:apply-templates/></xsl:template>
132 <xsl:template match="Indented"><p><div style="margin-left: 1em;"><xsl:apply-templates/></div></p></xsl:template>
133 <xsl:template match="img|table|br|td|tr|th">
134 <xsl:copy><xsl:for-each select="@*"><xsl:copy/></xsl:for-each><xsl:apply-templates/></xsl:copy>
135 </xsl:template>
136 <xsl:template match="i|b|u"><xsl:element name="{name()}"><xsl:apply-templates/></xsl:element></xsl:template>
137 <xsl:template match="File"><a href="../{@url}" target="_blank"><img src="../{@url}" width="{@width}" height="{@height}" border="0"/></a></xsl:template>
138 <xsl:template match="text()"><xsl:value-of select="."/></xsl:template>
139 <xsl:template match="Author"><b><xsl:apply-templates/></b></xsl:template>
140 <xsl:template match="Affiliation"><i><xsl:apply-templates/></i></xsl:template>
141 <xsl:template name="version_and_date"><p><b><xsl:apply-templates select="Version/Text"/></b>&#160;&#160;<xsl:apply-templates select="Date/Text"/></p></xsl:template>
142
143
144 <xsl:template match="Chapter|Appendix|Bibliography" mode="index">
145 <dt><a href="#Chapter_{@id}"><xsl:apply-templates select="Title/Text"/></a></dt>
146 <xsl:for-each select="Content/Section"><dd><a href="#Section_{@id}"><xsl:apply-templates select="Title/Text"/></a></dd></xsl:for-each>
147</xsl:template>
148
149
150 <xsl:template match="Section" mode="index">
151 <dt><a href="#Section_{@id}"><xsl:apply-templates select="Title/Text"/></a></dt>
152 </xsl:template>
153
154
155<xsl:template match="Chapter">
156 <a id="Chapter_{@id}"/>
157 <h2><xsl:if test="not(starts-with(@id, 'appendix')) and not(starts-with(@id, 'biblio'))">
158 <xsl:value-of select="position()"/></xsl:if>&#160;<xsl:apply-templates select="Title/Text"/></h2>
159 <xsl:apply-templates select="Content/*"/>
160</xsl:template>
161
162
163<xsl:template match="Figure" mode="ref">
164 <xsl:variable name="temp_total_figs"><xsl:number count="Figure" level="any"/></xsl:variable>
165 <xsl:variable name="temp_num_of_sub_figs">
166 <xsl:number count="Figure[Title/SubTitle and substring(translate(@id, '_0123456789', '99999999999'), string-length(@id)-1, string-length(@id))='99']" level="any"/>
167 </xsl:variable>
168 <xsl:variable name="no"><xsl:value-of select="$temp_total_figs - $temp_num_of_sub_figs"/></xsl:variable>
169 <xsl:variable name="subtitle">
170 <xsl:if test="Title/SubTitle"><xsl:value-of select="substring-before(substring-after(Title/SubTitle, '('), ')')"/></xsl:if>
171 </xsl:variable>
172 <xsl:value-of select="concat($no, $subtitle)"/>
173 </xsl:template>
174 <xsl:template match="Table" mode="ref"><xsl:number count="Table[not(@class='hidden')]" level="any"/></xsl:template>
175 <xsl:template match="Chapter" mode="ref"><xsl:number level="any"/></xsl:template>
176 <xsl:template match="Section" mode="ref"><xsl:number count="//Chapter|//Chapter//Section" format="1.1" level="multiple"/></xsl:template>
177 <xsl:template match="Subsection" mode="ref"><xsl:number level="multiple" format="1.1.1" count="//Chapter|//Chapter//Section|//Chapter//Section//Subsection"/></xsl:template>
178
179
180<xsl:template match="SupplementaryText">
181 <xsl:param name="manual_id" select="''"/>
182 <xsl:param name="manual_lang" select="''"/>
183 <xsl:for-each select="Text">
184 <div class="indexlink"><a class="indexlink">
185 <xsl:if test="@id='manual_index'"><xsl:attribute name="href"><xsl:value-of select="$manual_id"/>_<xsl:value-of select="$manual_lang"/>_index.html</xsl:attribute></xsl:if>
186 <xsl:if test="@id='top_index'"><xsl:attribute name="href">../../index.html</xsl:attribute></xsl:if>
187 <xsl:value-of select="."/></a></div>
188 </xsl:for-each>
189 </xsl:template>
190
191 <xsl:template match="Link">
192 <xsl:choose>
193 <xsl:when test="not(parent::Text)">
194 <p><div style="margin-left: 2em;">
195 <a><xsl:attribute name="href"><xsl:choose><xsl:when test="@url"><xsl:value-of select="@url"/></xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose></xsl:attribute><xsl:value-of select="."/></a>
196 </div></p>
197 </xsl:when>
198 <xsl:otherwise>
199 <a><xsl:attribute name="href"><xsl:choose><xsl:when test="@url"><xsl:value-of select="@url"/></xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose></xsl:attribute><xsl:value-of select="."/></a>
200 </xsl:otherwise>
201 </xsl:choose>
202 </xsl:template>
203</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.