| 1 |
<?xml version='1.0'?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:hl="java:net.sf.xslthl.ConnectorSaxon6" |
| 4 |
xmlns:exsl="http://exslt.org/common" |
| 5 |
exclude-result-prefixes="exsl hl" |
| 6 |
version='1.0'> |
| 7 |
|
| 8 |
<!-- ******************************************************************** |
| 9 |
$Id: common.xsl 7266 2007-08-22 11:58:42Z xmldoc $ |
| 10 |
******************************************************************** |
| 11 |
|
| 12 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 13 |
See ../README or http://docbook.sf.net/release/xsl/current/ for |
| 14 |
and other information. |
| 15 |
|
| 16 |
******************************************************************** --> |
| 17 |
|
| 18 |
<!-- You can override this template to do more complex mapping of |
| 19 |
language attribute to highlighter language ID (see xslthl-config.xml) --> |
| 20 |
<xsl:template name="language.to.xslthl"> |
| 21 |
<xsl:param name="context"/> |
| 22 |
|
| 23 |
<xsl:choose> |
| 24 |
<xsl:when test="$context/@language != ''"> |
| 25 |
<xsl:value-of select="$context/@language"/> |
| 26 |
</xsl:when> |
| 27 |
<xsl:when test="$highlight.default.language != ''"> |
| 28 |
<xsl:value-of select="$highlight.default.language"/> |
| 29 |
</xsl:when> |
| 30 |
</xsl:choose> |
| 31 |
</xsl:template> |
| 32 |
|
| 33 |
<xsl:template name="apply-highlighting"> |
| 34 |
<xsl:choose> |
| 35 |
<!-- Do we want syntax highlighting --> |
| 36 |
<xsl:when test="$highlight.source != 0 and function-available('hl:highlight')"> |
| 37 |
<xsl:variable name="language"> |
| 38 |
<xsl:call-template name="language.to.xslthl"> |
| 39 |
<xsl:with-param name="context" select="."/> |
| 40 |
</xsl:call-template> |
| 41 |
</xsl:variable> |
| 42 |
<xsl:choose> |
| 43 |
<xsl:when test="$language != ''"> |
| 44 |
<xsl:variable name="content"> |
| 45 |
<xsl:apply-templates/> |
| 46 |
</xsl:variable> |
| 47 |
<xsl:apply-templates select="hl:highlight($language, exsl:node-set($content))"/> |
| 48 |
</xsl:when> |
| 49 |
<xsl:otherwise> |
| 50 |
<xsl:apply-templates/> |
| 51 |
</xsl:otherwise> |
| 52 |
</xsl:choose> |
| 53 |
</xsl:when> |
| 54 |
<!-- No syntax highlighting --> |
| 55 |
<xsl:otherwise> |
| 56 |
<xsl:apply-templates/> |
| 57 |
</xsl:otherwise> |
| 58 |
</xsl:choose> |
| 59 |
</xsl:template> |
| 60 |
|
| 61 |
</xsl:stylesheet> |
| 62 |
|