| 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.makra.Skriptování" | 
|---|
| 23 | xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace" | 
|---|
| 24 | xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" | 
|---|
| 25 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | 
|---|
| 26 | exclude-result-prefixes="m j k s"> | 
|---|
| 27 |  | 
|---|
| 28 | <!-- | 
|---|
| 29 | Skriptování | 
|---|
| 30 | *********** | 
|---|
| 31 | Provedeme skript zadaný v těle elementu a jeho výstup vložíme do stránky. | 
|---|
| 32 | * | 
|---|
| 33 | @jazyk programovací jazyk, např. bash, perl, php | 
|---|
| 34 | @výstup formát výstupu skriptu: text (výchozí) | xml (musí být validním fragmentem XML) | 
|---|
| 35 | --> | 
|---|
| 36 | <xsl:template match="m:skript"> | 
|---|
| 37 |  | 
|---|
| 38 | <xsl:variable name="režim" select="$konfigurace/k:web/k:skriptování/k:režim/text()"/> | 
|---|
| 39 |  | 
|---|
| 40 | <xsl:choose> | 
|---|
| 41 | <xsl:when test="$režim = 'povolit'"> | 
|---|
| 42 | <xsl:variable name="výstupSkriptu" select="j:interpretuj( | 
|---|
| 43 | text(), | 
|---|
| 44 | @jazyk, | 
|---|
| 45 | @výstup, | 
|---|
| 46 | document-uri(/), | 
|---|
| 47 | //s:stránka/s:nadpis/text(), | 
|---|
| 48 | //s:stránka/s:perex/text() | 
|---|
| 49 | )"/> | 
|---|
| 50 | <xsl:choose> | 
|---|
| 51 | <xsl:when test="$výstupSkriptu"> | 
|---|
| 52 | <xsl:choose> | 
|---|
| 53 | <xsl:when test="@výstup = 'xml'"><xsl:value-of select="$výstupSkriptu" disable-output-escaping="yes"/></xsl:when> | 
|---|
| 54 | <xsl:otherwise><xsl:value-of select="$výstupSkriptu"/></xsl:otherwise> | 
|---|
| 55 | </xsl:choose> | 
|---|
| 56 | </xsl:when> | 
|---|
| 57 | <xsl:otherwise> | 
|---|
| 58 | <xsl:message terminate="yes">Při interpretaci skriptu došlo k chybě.</xsl:message> | 
|---|
| 59 | </xsl:otherwise> | 
|---|
| 60 | </xsl:choose> | 
|---|
| 61 | </xsl:when> | 
|---|
| 62 |  | 
|---|
| 63 | <xsl:when test="$režim = 'zakázat'"> | 
|---|
| 64 | <xsl:message terminate="yes">Stránka obsahuje skripty, ale skripty jsou zakázané → je potřeba je odstranit nebo upravit nastavení ve web.conf.</xsl:message> | 
|---|
| 65 | </xsl:when> | 
|---|
| 66 | <xsl:when test="$režim = 'ignorovat'"> | 
|---|
| 67 | <xsl:message>Stránka obsahuje skripty, ale skripty jsou ignorovány – změnu lze provést ve web.conf.</xsl:message> | 
|---|
| 68 | </xsl:when> | 
|---|
| 69 | <xsl:when test="$režim = 'vložit' and @výstup = 'xml'"> | 
|---|
| 70 | <xsl:message>Není možné jen tak vložit text, který měl mít výstup ve formátu XML – změnu lze provést ve web.conf</xsl:message> | 
|---|
| 71 | </xsl:when> | 
|---|
| 72 | <xsl:when test="$režim = 'vložit'"> | 
|---|
| 73 | <span class="vloženýNeinterpretovanýSkript jazyk-{@jazyk}"> | 
|---|
| 74 | <xsl:value-of select="text()"/> | 
|---|
| 75 | </span> | 
|---|
| 76 | </xsl:when> | 
|---|
| 77 | <xsl:otherwise><!-- varovat = výchozí možnost --> | 
|---|
| 78 | <xsl:choose> | 
|---|
| 79 | <xsl:when test="@výstup = 'xml'"> | 
|---|
| 80 | <xsl:message>Není možné možné vložit varování na místo, kde měl být skript generující XML – změnu lze provést ve web.conf</xsl:message> | 
|---|
| 81 | </xsl:when> | 
|---|
| 82 | <xsl:otherwise> | 
|---|
| 83 | <xsl:text>[VAROVÁNÍ (</xsl:text> | 
|---|
| 84 | <xsl:value-of select="@jazyk"/> | 
|---|
| 85 | <xsl:text>): skripty jsou vypnuté – lze je zapnout ve web.conf]</xsl:text> | 
|---|
| 86 | <xsl:message>Skript se neinterpretuje a vkládáme varování do stránky – změnu lze provést ve web.conf</xsl:message> | 
|---|
| 87 | </xsl:otherwise> | 
|---|
| 88 | </xsl:choose> | 
|---|
| 89 | </xsl:otherwise> | 
|---|
| 90 | </xsl:choose> | 
|---|
| 91 | </xsl:template> | 
|---|
| 92 |  | 
|---|
| 93 | </xsl:stylesheet> | 
|---|
| 94 |  | 
|---|