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