Debian Codegraph @

docbook-xsl-ns/highlighting/common.xsl

raw symbols SCIP
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:d="http://docbook.org/ns/docbook"
4 xmlns:s6hl="http://net.sf.xslthl/ConnectorSaxon6"
5 xmlns:sbhl="http://net.sf.xslthl/ConnectorSaxonB"
6 xmlns:xhl="http://net.sf.xslthl/ConnectorXalan"
7 xmlns:saxon6="http://icl.com/saxon"
8 xmlns:saxonb="http://saxon.sf.net/"
9 xmlns:xalan="http://xml.apache.org/xalan"
10 xmlns:exsl="http://exslt.org/common"
11 xmlns:xslthl="http://xslthl.sf.net"
12 exclude-result-prefixes="exsl xslthl s6hl sbhl xhl d"
13 version='1.0'>
14
15 <!-- ********************************************************************
16
17 This file is part of the XSL DocBook Stylesheet distribution.
18 See ../README or http://cdn.docbook.org/release/xsl/current/ for
19 and other information.
20
21 ******************************************************************** -->
22
23 <!-- this construction is needed to have the saxon and xalan connectors working alongside each other -->
24 <xalan:component prefix="xhl" functions="highlight">
25 <xalan:script lang="javaclass" src="xalan://net.sf.xslthl.ConnectorXalan" />
26 </xalan:component>
27
28 <!-- for saxon 6 -->
29 <saxon6:script implements-prefix="s6hl" language="java" src="java:net.sf.xslthl.ConnectorSaxon6" />
30
31 <!-- for saxon 8.5 and later -->
32 <saxonb:script implements-prefix="sbhl" language="java" src="java:net.sf.xslthl.ConnectorSaxonB" />
33
34
35 <!-- You can override this template to do more complex mapping of
36 language attribute to highlighter language ID (see xslthl-config.xml) -->
37 <xsl:template name="language.to.xslthl">
38 <xsl:param name="context"/>
39
40 <xsl:choose>
41 <xsl:when test="$context/@language != ''">
42 <xsl:value-of select="$context/@language"/>
43 </xsl:when>
44 <xsl:when test="$highlight.default.language != ''">
45 <xsl:value-of select="$highlight.default.language"/>
46 </xsl:when>
47 </xsl:choose>
48 </xsl:template>
49
50 <xsl:template name="apply-highlighting">
51 <xsl:choose>
52 <!-- Do we want syntax highlighting -->
53 <xsl:when test="$highlight.source != 0">
54 <xsl:variable name="language">
55 <xsl:call-template name="language.to.xslthl">
56 <xsl:with-param name="context" select="."/>
57 </xsl:call-template>
58 </xsl:variable>
59 <xsl:choose>
60 <xsl:when test="$language != ''">
61 <xsl:variable name="content">
62 <xsl:apply-templates/>
63 </xsl:variable>
64 <xsl:choose>
65 <xsl:when test="function-available('s6hl:highlight')">
66 <xsl:apply-templates select="s6hl:highlight($language, exsl:node-set($content), $highlight.xslthl.config)"
67 mode="xslthl"/>
68 </xsl:when>
69 <xsl:when test="function-available('sbhl:highlight')">
70 <xsl:apply-templates select="sbhl:highlight($language, exsl:node-set($content), $highlight.xslthl.config)"
71 mode="xslthl"/>
72 </xsl:when>
73 <xsl:when test="function-available('xhl:highlight')">
74 <xsl:apply-templates select="xhl:highlight($language, exsl:node-set($content), $highlight.xslthl.config)"
75 mode="xslthl"/>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:copy-of select="$content"/>
79 </xsl:otherwise>
80 </xsl:choose>
81 </xsl:when>
82 <xsl:otherwise>
83 <xsl:apply-templates/>
84 </xsl:otherwise>
85 </xsl:choose>
86 </xsl:when>
87 <!-- No syntax highlighting -->
88 <xsl:otherwise>
89 <xsl:apply-templates/>
90 </xsl:otherwise>
91 </xsl:choose>
92 </xsl:template>
93
94 <!-- A fallback when the specific style isn't recognized -->
95 <xsl:template match="xslthl:*" mode="xslthl">
96 <xsl:message>
97 <xsl:text>unprocessed xslthl style: </xsl:text>
98 <xsl:value-of select="local-name(.)" />
99 </xsl:message>
100 <xsl:apply-templates mode="xslthl"/>
101 </xsl:template>
102
103 <!-- Copy over already produced markup (FO/HTML) -->
104 <xsl:template match="node()" mode="xslthl" priority="-1">
105 <xsl:copy>
106 <xsl:apply-templates select="node()" mode="xslthl"/>
107 </xsl:copy>
108 </xsl:template>
109
110 <xsl:template match="*" mode="xslthl">
111 <xsl:copy>
112 <xsl:copy-of select="@*"/>
113 <xsl:apply-templates select="node()" mode="xslthl"/>
114 </xsl:copy>
115 </xsl:template>
116
117 </xsl:stylesheet>