root/šablona/stránka-společné.xsl @ 127:4b02189672db

Revision 127:4b02189672db, 5.5 KB (checked in by František Kučera <franta-hg@…>, 11 years ago)

XHTML metadata: klíčová slova

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