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