| 1 | <?xml version="1.0" encoding="UTF-8"?> | 
|---|
| 2 | <!-- | 
|---|
| 3 | XML Web generátor – program na generování webových stránek | 
|---|
| 4 | Copyright © 2012 František Kučera (frantovo.cz) | 
|---|
| 5 |  | 
|---|
| 6 | This program is free software: you can redistribute it and/or modify | 
|---|
| 7 | it under the terms of the GNU General Public License as published by | 
|---|
| 8 | the Free Software Foundation, either version 3 of the License, or | 
|---|
| 9 | (at your option) any later version. | 
|---|
| 10 |  | 
|---|
| 11 | This program is distributed in the hope that it will be useful, | 
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 14 | GNU General Public License for more details. | 
|---|
| 15 |  | 
|---|
| 16 | You should have received a copy of the GNU General Public License | 
|---|
| 17 | along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| 18 | --> | 
|---|
| 19 | <xsl:stylesheet version="2.0" | 
|---|
| 20 | xmlns="http://www.w3.org/1999/xhtml" | 
|---|
| 21 | xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro" | 
|---|
| 22 | xmlns:j="java:cz.frantovo.xmlWebGenerator.Funkce" | 
|---|
| 23 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | 
|---|
| 24 | exclude-result-prefixes="m j"> | 
|---|
| 25 |  | 
|---|
| 26 | <!-- | 
|---|
| 27 | Zvýraznění syntaxe zdrojového kódu | 
|---|
| 28 | ********************************** | 
|---|
| 29 | Ukázky zdrojového kódu budou mít zvýrazněnou syntaxi pro větší přehlednost. | 
|---|
| 30 | * | 
|---|
| 31 | @jazyk programovací jazyk, ve kterém je daný zdrojový kód | 
|---|
| 32 | @src zdrojový kód nemusí být uvnitř elementu, ale můžeme se odkázat na externí soubor | 
|---|
| 33 | @odkaz nastavíme hodnotu „ano“, pokud chceme vložit odkaz na soubor je stažení | 
|---|
| 34 | --> | 
|---|
| 35 | <xsl:template match="m:pre"> | 
|---|
| 36 | <xsl:call-template name="zvýrazniZdroják"> | 
|---|
| 37 | <xsl:with-param name="zdroják" select="text()"/> | 
|---|
| 38 | </xsl:call-template> | 
|---|
| 39 | </xsl:template> | 
|---|
| 40 |  | 
|---|
| 41 | <xsl:template match="m:pre[@src]"> | 
|---|
| 42 | <xsl:call-template name="zvýrazniZdroják"> | 
|---|
| 43 | <xsl:with-param name="zdroják" select="unparsed-text(concat('../', $vstup, @src))"/> | 
|---|
| 44 | </xsl:call-template> | 
|---|
| 45 | <xsl:if test="@odkaz = 'ano'"> | 
|---|
| 46 | <p class="zdroják-ke-stažení"> | 
|---|
| 47 | <span>Stáhnout: <a href="{encode-for-uri(@src)}"><xsl:value-of select="@src"/></a></span> | 
|---|
| 48 | </p> | 
|---|
| 49 | </xsl:if> | 
|---|
| 50 | </xsl:template> | 
|---|
| 51 |  | 
|---|
| 52 | <xsl:template name="zvýrazniZdroják"> | 
|---|
| 53 | <xsl:param name="zdroják"/> | 
|---|
| 54 | <xsl:variable name="zvýrazněnýZdroják" select="j:zvýrazniSyntaxi($zdroják, @jazyk)"/> | 
|---|
| 55 | <xsl:choose> | 
|---|
| 56 | <xsl:when test="$zvýrazněnýZdroják"> | 
|---|
| 57 | <xsl:comment>Následující kód je v jazyce <xsl:value-of select="@jazyk"/></xsl:comment> | 
|---|
| 58 | <xsl:value-of disable-output-escaping="yes" select="$zvýrazněnýZdroják"/> | 
|---|
| 59 | </xsl:when> | 
|---|
| 60 | <xsl:otherwise> | 
|---|
| 61 | <xsl:message>Zvýraznění syntaxe se nezdařilo → bude vložen původní nezvýrazněný kód.</xsl:message> | 
|---|
| 62 | <pre><xsl:value-of select="$zdroják"/></pre> | 
|---|
| 63 | </xsl:otherwise> | 
|---|
| 64 | </xsl:choose> | 
|---|
| 65 | </xsl:template> | 
|---|
| 66 |  | 
|---|
| 67 | </xsl:stylesheet> | 
|---|