1 <?xml version='1.0'?>
\r
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
\r
4 xmlns:s6hl="http://net.sf.xslthl/ConnectorSaxon6"
\r
5 xmlns:sbhl="http://net.sf.xslthl/ConnectorSaxonB"
\r
6 xmlns:xhl="http://net.sf.xslthl/ConnectorXalan"
\r
7 xmlns:saxon6="http://icl.com/saxon"
\r
8 xmlns:saxonb="http://saxon.sf.net/"
\r
9 xmlns:xalan="http://xml.apache.org/xalan"
\r
11 xmlns:exsl="http://exslt.org/common"
\r
12 xmlns:xslthl="http://xslthl.sf.net"
\r
13 exclude-result-prefixes="exsl xslthl s6hl sbhl xhl"
\r
16 <!-- ********************************************************************
\r
17 $Id: common.xsl 8257 2009-02-20 04:40:16Z abdelazer $
\r
18 ********************************************************************
\r
20 This file is part of the XSL DocBook Stylesheet distribution.
\r
21 See ../README or http://docbook.sf.net/release/xsl/current/ for
\r
22 and other information.
\r
24 ******************************************************************** -->
\r
26 <!-- this construction is needed to have the saxon and xalan connectors working alongside each other -->
\r
27 <xalan:component prefix="xhl" functions="highlight">
\r
28 <xalan:script lang="javaclass" src="xalan://net.sf.xslthl.ConnectorXalan" />
\r
31 <!-- for saxon 6 -->
\r
32 <saxon6:script implements-prefix="s6hl" language="java" src="java:net.sf.xslthl.ConnectorSaxon6" />
\r
34 <!-- for saxon 8.5 and later -->
\r
35 <saxonb:script implements-prefix="sbhl" language="java" src="java:net.sf.xslthl.ConnectorSaxonB" />
\r
38 <!-- You can override this template to do more complex mapping of
\r
39 language attribute to highlighter language ID (see xslthl-config.xml) -->
\r
40 <xsl:template name="language.to.xslthl">
\r
41 <xsl:param name="context"/>
\r
44 <xsl:when test="$context/@language != ''">
\r
45 <xsl:value-of select="$context/@language"/>
\r
47 <xsl:when test="$highlight.default.language != ''">
\r
48 <xsl:value-of select="$highlight.default.language"/>
\r
53 <xsl:template name="apply-highlighting">
\r
55 <!-- Do we want syntax highlighting -->
\r
56 <xsl:when test="$highlight.source != 0">
\r
57 <xsl:variable name="language">
\r
58 <xsl:call-template name="language.to.xslthl">
\r
59 <xsl:with-param name="context" select="."/>
\r
60 </xsl:call-template>
\r
63 <xsl:when test="$language != ''">
\r
64 <xsl:variable name="content">
\r
65 <xsl:apply-templates/>
\r
68 <xsl:when test="function-available('s6hl:highlight')">
\r
69 <xsl:apply-templates select="s6hl:highlight($language, exsl:node-set($content), $highlight.xslthl.config)"
\r
72 <xsl:when test="function-available('sbhl:highlight')">
\r
73 <xsl:apply-templates select="sbhl:highlight($language, exsl:node-set($content), $highlight.xslthl.config)"
\r
76 <xsl:when test="function-available('xhl:highlight')">
\r
77 <xsl:apply-templates select="xhl:highlight($language, exsl:node-set($content), $highlight.xslthl.config)"
\r
81 <xsl:copy-of select="$content"/>
\r
86 <xsl:apply-templates/>
\r
90 <!-- No syntax highlighting -->
\r
92 <xsl:apply-templates/>
\r
97 <!-- A fallback when the specific style isn't recognized -->
\r
98 <xsl:template match="xslthl:*" mode="xslthl">
\r
100 <xsl:text>unprocessed xslthl style: </xsl:text>
\r
101 <xsl:value-of select="local-name(.)" />
\r
103 <xsl:apply-templates mode="xslthl"/>
\r
106 <!-- Copy over already produced markup (FO/HTML) -->
\r
107 <xsl:template match="node()" mode="xslthl" priority="-1">
\r
109 <xsl:apply-templates select="node()" mode="xslthl"/>
\r
113 <xsl:template match="*" mode="xslthl">
\r
115 <xsl:copy-of select="@*"/>
\r
116 <xsl:apply-templates select="node()" mode="xslthl"/>
\r