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