root/šablona/stránka-společné.xsl @ 71:895757141bff

Revision 71:895757141bff, 3.4 KB (checked in by František Kučera <franta-hg@…>, 12 years ago)

Funkce pro načítání textových souborů ze vstupního adresáře (vhodné pro @src).

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        <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    <!-- Varování pro případ, že jsme v režimu podpory pro zaostalé prohlížeče -->
53    <xsl:template name="varováníRetardace">
54        <xsl:if test="$podporaZaostalýchProhlížečů">
55                        <xsl:comment>
56                                Generátor byl spuštěn v režimu podpory zaostalých prohlížečů.
57                                Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč,
58                                jako je např. Firefox nebo Chromium (případně Opera či Safari).
59                        </xsl:comment>
60        </xsl:if>
61    </xsl:template>
62
63    <!-- Odkazy na JavaScript a kaskádové styly -->   
64    <xsl:template match="k:web/k:js">           
65        <script src="{text()}" type="text/javascript">
66                <xsl:call-template name="varováníRetardace"/>
67        </script>
68    </xsl:template>
69    <xsl:template match="k:web/k:css">
70        <link href="{text()}" type="text/css" rel="StyleSheet" />
71    </xsl:template>
72   
73    <xsl:function name="m:escapuj-url-zachovej-lomítka" as="xs:string">
74                <xsl:param name="cesta"/>
75                <xsl:value-of select="replace(encode-for-uri($cesta), '%2F', '/')"/>
76        </xsl:function>
77       
78        <!--
79                Vrací obsah textového souboru ve vstupním adresáři.
80                Obvykle jako parametr předáváme atribut „src“.
81        -->
82        <xsl:function name="m:načti-textový-soubor" as="xs:string">
83                <xsl:param name="soubor"/>
84                <xsl:value-of select="unparsed-text(concat($vstup, $soubor))"/>
85        </xsl:function>
86   
87</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.