[51] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
[61] | 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 | --> |
---|
[51] | 19 | <xsl:stylesheet version="2.0" |
---|
| 20 | xmlns="http://www.w3.org/1999/xhtml" |
---|
| 21 | xmlns:h="http://www.w3.org/1999/xhtml" |
---|
| 22 | xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
---|
| 23 | xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace" |
---|
| 24 | xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro" |
---|
| 25 | xmlns:j="java:cz.frantovo.xmlWebGenerator.Funkce" |
---|
| 26 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
| 27 | xmlns:fn="http://www.w3.org/2005/xpath-functions" |
---|
| 28 | xmlns:svg="http://www.w3.org/2000/svg" |
---|
| 29 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
| 30 | exclude-result-prefixes="fn h s k m j xs"> |
---|
| 31 | |
---|
| 32 | <xsl:param name="vstup" select="'../vstup/'"/> |
---|
| 33 | <xsl:param name="výstup" select="'../výstup/'"/> |
---|
| 34 | <xsl:param name="vstupníPřípona" select="'.xml'"/> |
---|
| 35 | <xsl:param name="výstupníPřípona" select="'.xhtml'"/> |
---|
| 36 | <xsl:param name="vsuvkováPřípona" select="'.inc'"/> |
---|
| 37 | <xsl:param name="podporaZaostalýchProhlížečů" select="false()" as="xs:boolean"/> |
---|
[77] | 38 | |
---|
[51] | 39 | <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/> |
---|
| 40 | |
---|
| 41 | <xsl:include href=".makra-seznam.xsl"/> |
---|
| 42 | |
---|
[87] | 43 | <!-- |
---|
| 44 | Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: |
---|
[77] | 45 | --> |
---|
[51] | 46 | <xsl:template match="*"> |
---|
| 47 | <xsl:element name="{name()}"> |
---|
| 48 | <xsl:copy-of select="@*"/> |
---|
| 49 | <xsl:apply-templates/> |
---|
| 50 | </xsl:element> |
---|
[77] | 51 | </xsl:template> |
---|
[87] | 52 | |
---|
| 53 | <!-- |
---|
| 54 | Varování pro případ, že jsme v režimu podpory pro zaostalé prohlížeče |
---|
[77] | 55 | --> |
---|
| 56 | <xsl:template name="varováníRetardace"> |
---|
| 57 | <xsl:if test="$podporaZaostalýchProhlížečů"> |
---|
[132] | 58 | <xsl:comment>PZP</xsl:comment> |
---|
| 59 | </xsl:if> |
---|
| 60 | </xsl:template> |
---|
| 61 | |
---|
| 62 | <xsl:template name="varováníRetardaceDlouhé"> |
---|
| 63 | <xsl:if test="$podporaZaostalýchProhlížečů"> |
---|
[51] | 64 | <xsl:comment> |
---|
[132] | 65 | Generátor byl spuštěn v režimu podpory zaostalých prohlížečů (PZP). |
---|
[51] | 66 | Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč, |
---|
[131] | 67 | jako je např. GNU IceCat, Firefox nebo rekonq. |
---|
[51] | 68 | </xsl:comment> |
---|
[77] | 69 | </xsl:if> |
---|
| 70 | </xsl:template> |
---|
[132] | 71 | |
---|
| 72 | <xsl:template match="h:textarea"> |
---|
| 73 | <xsl:element name="{name()}"> |
---|
| 74 | <xsl:copy-of select="@*"/> |
---|
| 75 | <xsl:call-template name="varováníRetardace"/> |
---|
| 76 | <xsl:apply-templates/> |
---|
| 77 | </xsl:element> |
---|
| 78 | </xsl:template> |
---|
[87] | 79 | |
---|
[126] | 80 | <!-- |
---|
[87] | 81 | Odkazy na JavaScript a kaskádové styly |
---|
[126] | 82 | --> |
---|
[87] | 83 | <xsl:template match="k:web/k:js"> |
---|
[77] | 84 | <script src="{text()}" type="text/javascript"> |
---|
| 85 | <xsl:call-template name="varováníRetardace"/> |
---|
| 86 | </script> |
---|
| 87 | </xsl:template> |
---|
| 88 | <xsl:template match="k:web/k:css"> |
---|
| 89 | <link href="{text()}" type="text/css" rel="StyleSheet" /> |
---|
| 90 | </xsl:template> |
---|
[126] | 91 | |
---|
| 92 | <!-- |
---|
| 93 | Metainformace o autorovi a popisu stránky |
---|
| 94 | --> |
---|
| 95 | <xsl:template match="k:web/k:autor/k:jméno"> |
---|
| 96 | <meta content="{text()}" name="author"/> |
---|
| 97 | </xsl:template> |
---|
| 98 | <xsl:template match="s:stránka/s:perex"> |
---|
| 99 | <meta content="{text()}" name="description"/> |
---|
| 100 | </xsl:template> |
---|
[127] | 101 | <xsl:template match="s:stránka/s:klíčováSlova"> |
---|
| 102 | <xsl:element name="meta"> |
---|
| 103 | <xsl:attribute name="content"> |
---|
| 104 | <xsl:for-each select="s:slovo"> |
---|
| 105 | <xsl:value-of select="text()"/> |
---|
| 106 | <xsl:if test="not(position() = last())">, </xsl:if> |
---|
| 107 | </xsl:for-each> |
---|
| 108 | </xsl:attribute> |
---|
| 109 | <xsl:attribute name="name">keywords</xsl:attribute> |
---|
| 110 | </xsl:element> |
---|
| 111 | </xsl:template> |
---|
[87] | 112 | |
---|
| 113 | <!-- |
---|
| 114 | Vloží nečíslovaný seznam obsahující hlavní nabídku webu (seznam stránek) |
---|
| 115 | Pro potřeby CSS stylování má nabídka @id='nabídka' |
---|
| 116 | --> |
---|
[77] | 117 | <xsl:template name="vložNabídku"> |
---|
| 118 | <ul id="nabídka"> |
---|
| 119 | <xsl:for-each select="collection(concat('./', $vstup ,'/?select=*', $vstupníPřípona))[s:stránka/s:pořadí]"> |
---|
| 120 | <xsl:sort select="empty(./s:stránka/s:pořadí)"/> |
---|
| 121 | <xsl:sort select="./s:stránka/s:pořadí"/> |
---|
| 122 | <li> |
---|
| 123 | <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/> |
---|
| 124 | <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/> |
---|
| 125 | <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./s:stránka/s:nadpis"/></a> |
---|
| 126 | </li> |
---|
| 127 | </xsl:for-each> |
---|
| 128 | </ul> |
---|
| 129 | </xsl:template> |
---|
[87] | 130 | |
---|
[77] | 131 | <!-- |
---|
| 132 | Vloží záhlaví (společné pro všechny stránky) |
---|
| 133 | Pro potřeby CSS stylování má @id='záhlaví' |
---|
| 134 | --> |
---|
| 135 | <xsl:template name="vložZáhlaví"> |
---|
| 136 | <div id="záhlaví"> |
---|
| 137 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví', $vsuvkováPřípona)))/s:stránka/h:text/node()"/> |
---|
| 138 | </div> |
---|
| 139 | </xsl:template> |
---|
[87] | 140 | |
---|
[77] | 141 | <!-- |
---|
| 142 | Vloží zápatí (společné pro všechny stránky) |
---|
| 143 | Pro potřeby CSS stylování má @id='zápatí' |
---|
| 144 | --> |
---|
| 145 | <xsl:template name="vložZápatí"> |
---|
| 146 | <div id="zápatí"> |
---|
| 147 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí', $vsuvkováPřípona)))/s:stránka/h:text/node()"/> |
---|
| 148 | </div> |
---|
| 149 | </xsl:template> |
---|
[51] | 150 | |
---|
[87] | 151 | <!-- |
---|
| 152 | Vrací cestu v URL kódování, ale lomítka nekóduje |
---|
| 153 | --> |
---|
| 154 | <xsl:function name="m:escapuj-url-zachovej-lomítka" as="xs:string"> |
---|
[71] | 155 | <xsl:param name="cesta"/> |
---|
| 156 | <xsl:value-of select="replace(encode-for-uri($cesta), '%2F', '/')"/> |
---|
| 157 | </xsl:function> |
---|
[87] | 158 | |
---|
[71] | 159 | <!-- |
---|
| 160 | Vrací obsah textového souboru ve vstupním adresáři. |
---|
| 161 | Obvykle jako parametr předáváme atribut „src“. |
---|
| 162 | --> |
---|
| 163 | <xsl:function name="m:načti-textový-soubor" as="xs:string"> |
---|
| 164 | <xsl:param name="soubor"/> |
---|
| 165 | <xsl:value-of select="unparsed-text(concat($vstup, $soubor))"/> |
---|
| 166 | </xsl:function> |
---|
[87] | 167 | |
---|
[51] | 168 | </xsl:stylesheet> |
---|
[87] | 169 | |
---|