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