source: trunk/lib/docbook/custom-styles/docbook/plain/xsl/customized.chunked.xsl @ 6417

Last change on this file since 6417 was 6417, checked in by Nicklas Nordborg, 9 years ago

References #1712: Implement a 'Content Security Policy'

Added support for relaxing the security policy for extensions that asks for it by setting <about safe-resources="0"> in their extensions.xml definition file.

  • Property svn:eol-style set to native
File size: 13.2 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:fo="http://www.w3.org/1999/XSL/Format"
4                xmlns:date="http://exslt.org/dates-and-times"
5                exclude-result-prefixes="date"
6                version='1.0'>
7
8<xsl:import href="../../../lib/docbook/docbook/xsl/html/chunk.xsl" />
9
10<!-- (MM20040315) xsl parameters moved from ant-build-docbook.xml to here -->
11<xsl:param name="table.borders.with.css" select="1"/>
12<xsl:param name="html.stylesheet">css/docbook.css</xsl:param>
13<xsl:param name="html.stylesheet.type">text/css</xsl:param>       
14<xsl:param name="section.label.includes.component.label" select="1" />         
15<xsl:param name="section.autolabel" select="1" />
16<xsl:param name="section.autolabel.max.depth" select="2" />
17<xsl:param name="chunk.first.sections" select="1" />
18<xsl:param name="chunk.section.depth" select="2" />
19<xsl:param name="chunk.fast" select="1" />
20<xsl:param name="toc.max.depth" select="4"/>
21<xsl:param name="toc.section.depth" select="3" />
22<xsl:param name="generate.section.toc.level" select="1" />
23<xsl:param name="generate.toc">
24appendix  toc,title
25article/appendix  nop
26article   toc,title
27book      toc,title
28chapter   toc,title
29part      toc,title
30preface   toc,title
31qandadiv  toc
32qandaset  toc
33reference toc,title
34sect1     toc
35sect2     toc
36sect3     toc
37sect4     toc
38sect5     toc
39section   toc
40set       toc,title
41</xsl:param>
42<!-- Turn off image scaling when generating HTML output -->
43<xsl:param name="make.graphic.viewport" select="0"/>
44<xsl:param name="ignore.image.scaling" select="1"/>
45
46<xsl:param name="callout.graphics" select="1" />
47<xsl:param name="callout.graphics.path">gfx/admonitions/callouts/</xsl:param>
48<xsl:param name="callout.graphics.extension">.gif</xsl:param>
49<xsl:param name="admon.graphics" select="1"/>
50<xsl:param name="admon.graphics.path">gfx/admonitions/</xsl:param>
51<xsl:param name="admon.graphics.extension">.png</xsl:param>
52<xsl:param name="admon.style"></xsl:param>
53<xsl:param name="admonition.title.properties">text-align: left</xsl:param>
54<!-- xsl:param name="menuchoice.menu.separator">&#9658;</xsl:param-->
55<xsl:param name="menuchoice.menu.separator"></xsl:param>
56
57<xsl:param name="keep.relative.image.uris" select="false"/>
58<xsl:param name="use.id.as.filename" select="1"/>
59
60<!--  path to javadoc root as seen from docbook root -->
61<xsl:param name="javadoc.root.path">../api/</xsl:param>
62
63<xsl:param name="chunker.output.encoding">utf-8</xsl:param>
64<xsl:param name="chunker.output.doctype-public">-//W3C//DTD HTML 4.01 Transitional//EN</xsl:param>
65<xsl:param name="chunker.output.doctype-system">http://www.w3.org/TR/html4/loose.dtd</xsl:param>
66<xsl:param name="chunker.output.indent">yes</xsl:param>
67<xsl:param name="chunker.message.nofilename">1</xsl:param>
68
69<!-- (MM20040315) base.dir and root.filename are coming from the ant-build-docbook.xml -->
70<xsl:param name="base.dir">@base.dir@/</xsl:param>
71<xsl:param name="root.filename">@root.filename@</xsl:param>
72
73<!-- doc.revision and doc.last.modified -->
74<xsl:param name="doc.revision">@doc.revision@</xsl:param>
75<xsl:param name="doc.last.modified">@doc.last.modified@</xsl:param>
76<xsl:param name="base.version">@base.version@</xsl:param>
77
78<!-- convert url-only references to a format that is wrappable -->
79
80<xsl:template match="ulink" name="ulink">
81  <xsl:choose>
82  <xsl:when test="count(child::node())=0">
83  <a>
84      <xsl:if test="@id">
85        <xsl:attribute name="name">
86          <xsl:value-of select="@id"/>
87        </xsl:attribute>
88      </xsl:if>
89      <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
90      <xsl:if test="$ulink.target != ''">
91        <xsl:attribute name="target">
92          <xsl:value-of select="$ulink.target"/>
93        </xsl:attribute>
94      </xsl:if> 
95    <xsl:if test="count(child::node())=0">
96        <xsl:call-template name="insertInvisibleBreaks">
97            <xsl:with-param name="url" select="@url" />
98            <xsl:with-param name="breakat" select="translate(@url, '/-_:', '____')" />
99        </xsl:call-template>
100    </xsl:if>
101  </a>
102  </xsl:when>
103  <xsl:otherwise>
104  <xsl:apply-imports/>
105  </xsl:otherwise>
106  </xsl:choose>
107</xsl:template> 
108
109<xsl:template name="insertInvisibleBreaks">
110    <xsl:param name="url" />
111    <xsl:param name="breakat" />
112    <!-- <xsl:message><xsl:value-of select="concat('param:', $url, $breakat)" /></xsl:message> -->
113    <xsl:choose>
114        <xsl:when test="contains($breakat, '_')">
115            <xsl:value-of select="substring($url, 1, string-length(substring-before($breakat, '_'))+1)" /><wbr/>
116            <xsl:call-template name="insertInvisibleBreaks">
117                <xsl:with-param name="url" select="substring($url, string-length(substring-before($breakat, '_'))+2)"/>
118                <xsl:with-param name="breakat" select="substring($breakat, string-length(substring-before($breakat, '_'))+2)"/>
119            </xsl:call-template>
120        </xsl:when>
121        <xsl:otherwise>
122            <xsl:value-of select="$url" />
123        </xsl:otherwise>
124    </xsl:choose>
125</xsl:template>
126
127<!-- Base specific templates -->
128
129<xsl:template match="helptext">
130  <xsl:choose>
131    <xsl:when test="@webonly = '0'"> 
132      <xsl:apply-templates />
133    </xsl:when>
134  </xsl:choose>
135</xsl:template>
136
137<xsl:template match="seeother|other">
138</xsl:template>
139
140<xsl:template match="nohelp">
141  <xsl:apply-templates />
142</xsl:template>
143
144<xsl:template match="command">
145  <xsl:call-template name="inline.monoseq"/>
146</xsl:template>
147
148<xsl:template name="script">
149  <xsl:param name="src"></xsl:param>
150  <script>
151    <xsl:attribute name="language">JavaScript</xsl:attribute>
152    <xsl:attribute name="type">text/javascript</xsl:attribute>
153    <xsl:attribute name="src"><xsl:value-of select="$src" /></xsl:attribute>
154  </script>
155</xsl:template>
156
157<xsl:template name="user.head.content">
158  <xsl:variable name="pathtorootdir">
159    <xsl:call-template name="pathtorootdir" />
160  </xsl:variable>
161  <link rel="stylesheet"
162    type="text/css"
163    href="{concat($pathtorootdir, 'css/SyntaxHighlighter.css')}">
164  </link>
165  <xsl:call-template name="script">
166    <xsl:with-param name="src" select="concat($pathtorootdir, 'script/shCore.js')" />
167  </xsl:call-template>
168  <xsl:call-template name="script">
169    <xsl:with-param name="src" select="concat($pathtorootdir, 'script/shBrushJava.js')" />
170  </xsl:call-template>
171  <xsl:call-template name="script">
172    <xsl:with-param name="src" select="concat($pathtorootdir, 'script/shBrushXml.js')" />
173  </xsl:call-template>
174  <xsl:call-template name="script">
175    <xsl:with-param name="src" select="concat($pathtorootdir, 'script/shBrushSql.js')" />
176  </xsl:call-template>
177  <xsl:call-template name="script">
178    <xsl:with-param name="src" select="concat($pathtorootdir, 'script/shBrushJScript.js')" />
179  </xsl:call-template>
180</xsl:template>
181
182<xsl:template name="body.attributes">
183  <xsl:attribute name="onLoad">dp.SyntaxHighlighter.HighlightAll('pre', 'programlisting', null, false);</xsl:attribute>
184</xsl:template>
185
186<xsl:template name="user.footer.navigation">
187  <table width="100%" border="0" cellspacing="0" cellpadding="0">
188  <tr valign="bottom"><td>
189  <div 
190    class="navfooter"
191    align="left">
192    <i>
193      <xsl:if test="$doc.revision" >
194        Version: <xsl:value-of select="$base.version"/> (build #<xsl:value-of select="$doc.revision"/>);
195      </xsl:if>
196      <xsl:if test="$doc.last.modified" >
197        Last modified: <xsl:value-of select="$doc.last.modified" />;
198      </xsl:if>
199    </i>
200  </div>
201  </td>
202  <td>
203    <div class="navfooter" align="right">
204    <i>
205    Syntax coloring provided by <a href="http://alexgorbatchev.com/SyntaxHighlighter/">dp.SyntaxHighlighter</a>
206    </i>
207    </div>
208  </td>
209  </tr>
210  </table>
211</xsl:template>
212
213  <xsl:template name="convertpath">
214    <xsl:param name="path" select="''" />
215    <xsl:choose>
216      <xsl:when test="contains($path, '/')">
217        <xsl:text>../</xsl:text>
218        <xsl:call-template name="convertpath">
219          <xsl:with-param name="path" select="substring-after($path, '/')" />
220        </xsl:call-template>
221      </xsl:when>
222    </xsl:choose>
223  </xsl:template>
224
225  <xsl:template name="pathtorootdir">
226    <xsl:variable name="dir">
227      <xsl:call-template name="dbhtml-dir">
228        <xsl:with-param name="context" select="." />
229      </xsl:call-template>
230    </xsl:variable>
231    <xsl:call-template name="convertpath">
232      <xsl:with-param name="path" select="$dir" />
233    </xsl:call-template>
234  </xsl:template>
235
236  <xsl:template name="output.html.stylesheets">
237    <xsl:param name="stylesheets" select="''" />
238    <xsl:variable name="pathtorootdir">
239      <xsl:call-template name="pathtorootdir" />
240    </xsl:variable>
241    <xsl:choose>
242      <xsl:when test="contains($stylesheets, ' ')">
243        <link rel="stylesheet"
244          href="{substring-before(concat($pathtorootdir, $stylesheets), ' ')}">
245          <xsl:if test="$html.stylesheet.type != ''">
246            <xsl:attribute name="type">
247              <xsl:value-of select="$html.stylesheet.type" />
248            </xsl:attribute>
249          </xsl:if>
250        </link>
251        <xsl:call-template name="output.html.stylesheets">
252          <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')" />
253        </xsl:call-template>
254      </xsl:when>
255      <xsl:when test="$stylesheets != ''">
256        <link rel="stylesheet" href="{concat($pathtorootdir,$stylesheets)}">
257          <xsl:if test="$html.stylesheet.type != ''">
258            <xsl:attribute name="type">
259              <xsl:value-of select="$html.stylesheet.type" />
260            </xsl:attribute>
261          </xsl:if>
262        </link>
263      </xsl:when>
264    </xsl:choose>
265  </xsl:template>
266 
267  <xsl:template name="admon.graphic">
268    <xsl:param name="node" select="." />
269    <xsl:variable name="pathtorootdir">
270      <xsl:call-template name="pathtorootdir"/>
271    </xsl:variable>
272    <xsl:value-of select="concat($pathtorootdir, $admon.graphics.path)" />
273    <xsl:choose>
274      <xsl:when test="local-name($node)='note'">note</xsl:when>
275      <xsl:when test="local-name($node)='warning'">warning</xsl:when>
276      <xsl:when test="local-name($node)='caution'">caution</xsl:when>
277      <xsl:when test="local-name($node)='tip'">tip</xsl:when>
278      <xsl:when test="local-name($node)='important'">important</xsl:when>
279      <xsl:otherwise>note</xsl:otherwise>
280    </xsl:choose>
281    <xsl:value-of select="$admon.graphics.extension" />
282  </xsl:template>
283 
284  <xsl:template match="*" mode="admon.graphic.width">
285    <xsl:param name="node" select="."/>
286    <xsl:text>32</xsl:text>
287  </xsl:template>
288 
289  <xsl:template match="note|warning|tip|important|caution" mode="class.attribute">
290    <xsl:param name="class" select="local-name(.)"/>
291    <!-- permit customization of class attributes -->
292    <!-- Use element name by default -->
293    <xsl:attribute name="class">
294      <xsl:value-of select="concat('admonition ', $class)"/>
295    </xsl:attribute>
296  </xsl:template>
297 
298  <xsl:template match="classname">
299    <xsl:call-template name="inline.monoseq"/>
300    <xsl:call-template name="linkToJavadoc" />
301  </xsl:template>
302 
303  <xsl:template match="interfacename">
304    <xsl:call-template name="inline.monoseq"/>
305    <xsl:call-template name="linkToJavadoc" />
306  </xsl:template>
307 
308  <xsl:template name="linkToJavadoc">
309    <xsl:if test = "@docapi != ''">
310        <xsl:variable name="cleanClassName">
311          <xsl:choose>
312            <xsl:when test="starts-with(., @docapi)">
313              <xsl:value-of select="substring-after(., concat(@docapi, '.'))" />
314            </xsl:when>
315            <xsl:otherwise>
316              <xsl:value-of select="." />
317            </xsl:otherwise>
318          </xsl:choose>                     
319        </xsl:variable>
320       
321        <xsl:variable name="fullClassName">
322            <xsl:value-of select="concat(@docapi, '.', $cleanClassName)"/>
323        </xsl:variable>
324
325      <xsl:variable name="classPath">
326        <xsl:call-template name="replaceCharsInString">
327          <xsl:with-param name="stringIn" select="$fullClassName"/>
328          <xsl:with-param name="charsIn" select="'.'" />
329          <xsl:with-param name="charsOut" select="'/'" />
330        </xsl:call-template>
331        </xsl:variable>
332       
333        <xsl:variable name="pathtorootdir">
334          <xsl:call-template name="pathtorootdir" />
335        </xsl:variable>
336       
337      <a>
338        <xsl:attribute name="href">
339          <xsl:value-of select="concat($pathtorootdir, $javadoc.root.path, $classPath, '.html')" />
340        </xsl:attribute>
341        <xsl:attribute name="title">
342          <xsl:value-of select="concat('Javadoc for ', $fullClassName)" />
343        </xsl:attribute>
344        <img>
345          <xsl:attribute name="src">
346          <xsl:value-of select="concat($pathtorootdir, $admon.graphics.path, 'docapi.gif')"/>
347          </xsl:attribute> 
348          <xsl:attribute name="style">padding-left: 4px;</xsl:attribute>
349          <xsl:attribute name="border">0</xsl:attribute>
350        </img>
351      </a>
352    </xsl:if> 
353  </xsl:template>
354 
355  <xsl:template name="replaceCharsInString">
356      <xsl:param name="stringIn"/>
357      <xsl:param name="charsIn"/>
358      <xsl:param name="charsOut"/>
359      <xsl:choose>
360      <xsl:when test="contains($stringIn,$charsIn)">
361          <xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/>
362          <xsl:call-template name="replaceCharsInString">
363            <xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/>
364            <xsl:with-param name="charsIn" select="$charsIn"/>
365            <xsl:with-param name="charsOut" select="$charsOut"/>
366          </xsl:call-template>
367      </xsl:when>
368      <xsl:otherwise>
369          <xsl:value-of select="$stringIn"/>
370        </xsl:otherwise>
371      </xsl:choose>
372  </xsl:template>
373
374  <xsl:template match="lastmodified">
375    <xsl:value-of select="$doc.last.modified"/> 
376  </xsl:template>
377 
378  <xsl:template match="baseversion">
379    <xsl:value-of select="$base.version"/> 
380  </xsl:template>
381
382</xsl:stylesheet>
383
384
Note: See TracBrowser for help on using the repository browser.