root/šablona/stránka-společné.xsl

Revision 136:d5feb9d8ebc3, 5.8 KB (checked in by František Kučera <franta-hg@…>, 5 years ago)

fix license version: GNU GPLv3

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3XML Web generátor – program na generování webových stránek
4Copyright © 2012 František Kučera (frantovo.cz)
5
6This program is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, version 3 of the License.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program.  If not, see <http://www.gnu.org/licenses/>.
17-->
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"/>
37       
38        <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/>
39       
40        <xsl:include href=".makra-seznam.xsl"/>
41       
42        <!--
43                Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace:
44        -->
45        <xsl:template match="*">
46                <xsl:element name="{name()}">
47                        <xsl:copy-of select="@*"/>
48                        <xsl:apply-templates/>
49                </xsl:element>
50        </xsl:template>
51
52        <!--
53                Varování pro případ, že jsme v režimu podpory pro zaostalé prohlížeče
54        -->
55        <xsl:template name="varováníRetardace">
56                <xsl:if test="$podporaZaostalýchProhlížečů">
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čů">
63                        <xsl:comment>
64                                Generátor byl spuštěn v režimu podpory zaostalých prohlížečů (PZP).
65                                Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč,
66                                jako je např. GNU IceCat, Firefox nebo rekonq.
67                        </xsl:comment>
68                </xsl:if>
69        </xsl:template>
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>
78
79        <!--
80                Odkazy na JavaScript a kaskádové styly
81        -->
82        <xsl:template match="k:web/k:js">
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>
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>
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>
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        -->
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>
129
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>
139
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>
149
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">
154                <xsl:param name="cesta"/>
155                <xsl:value-of select="replace(encode-for-uri($cesta), '%2F', '/')"/>
156        </xsl:function>
157
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>
166
167</xsl:stylesheet>
168
Note: See TracBrowser for help on using the browser.