šablona/stránka-společné.xsl
author František Kučera <franta-hg@frantovo.cz>
Sun, 23 Jun 2013 16:29:22 +0200
changeset 126 be52f52e7d39
parent 87 25dec6931f18
child 127 4b02189672db
permissions -rw-r--r--
XHTML metadata: autor + popis stránky
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@51
    58
			<xsl:comment>
franta-hg@51
    59
				Generátor byl spuštěn v režimu podpory zaostalých prohlížečů.
franta-hg@51
    60
				Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč,
franta-hg@51
    61
				jako je např. Firefox nebo Chromium (případně Opera či Safari).
franta-hg@51
    62
			</xsl:comment>
franta-hg@77
    63
		</xsl:if>
franta-hg@77
    64
	</xsl:template>
franta-hg@87
    65
franta-hg@126
    66
	<!--
franta-hg@87
    67
		Odkazy na JavaScript a kaskádové styly
franta-hg@126
    68
	-->
franta-hg@87
    69
	<xsl:template match="k:web/k:js">
franta-hg@77
    70
		<script src="{text()}" type="text/javascript">
franta-hg@77
    71
			<xsl:call-template name="varováníRetardace"/>
franta-hg@77
    72
		</script>
franta-hg@77
    73
	</xsl:template>
franta-hg@77
    74
	<xsl:template match="k:web/k:css">
franta-hg@77
    75
		<link href="{text()}" type="text/css" rel="StyleSheet" />
franta-hg@77
    76
	</xsl:template>
franta-hg@126
    77
	
franta-hg@126
    78
	<!--
franta-hg@126
    79
		Metainformace o autorovi a popisu stránky
franta-hg@126
    80
	-->
franta-hg@126
    81
	<xsl:template match="k:web/k:autor/k:jméno">
franta-hg@126
    82
		<meta content="{text()}" name="author"/>
franta-hg@126
    83
	</xsl:template>
franta-hg@126
    84
	<xsl:template match="s:stránka/s:perex">
franta-hg@126
    85
		<meta content="{text()}" name="description"/>
franta-hg@126
    86
	</xsl:template>
franta-hg@87
    87
franta-hg@87
    88
	<!--
franta-hg@87
    89
		Vloží nečíslovaný seznam obsahující hlavní nabídku webu (seznam stránek)
franta-hg@87
    90
		Pro potřeby CSS stylování má nabídka @id='nabídka'
franta-hg@87
    91
	-->
franta-hg@77
    92
	<xsl:template name="vložNabídku">
franta-hg@77
    93
		<ul id="nabídka">
franta-hg@77
    94
			<xsl:for-each select="collection(concat('./', $vstup ,'/?select=*', $vstupníPřípona))[s:stránka/s:pořadí]">
franta-hg@77
    95
				<xsl:sort select="empty(./s:stránka/s:pořadí)"/>
franta-hg@77
    96
				<xsl:sort select="./s:stránka/s:pořadí"/>
franta-hg@77
    97
				<li>
franta-hg@77
    98
					<xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/>
franta-hg@77
    99
					<xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/>
franta-hg@77
   100
					<a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./s:stránka/s:nadpis"/></a>
franta-hg@77
   101
				</li>
franta-hg@77
   102
			</xsl:for-each>
franta-hg@77
   103
		</ul>
franta-hg@77
   104
	</xsl:template>
franta-hg@87
   105
franta-hg@77
   106
	<!--
franta-hg@77
   107
		Vloží záhlaví (společné pro všechny stránky)
franta-hg@77
   108
		Pro potřeby CSS stylování má @id='záhlaví'
franta-hg@77
   109
	-->
franta-hg@77
   110
	<xsl:template name="vložZáhlaví">
franta-hg@77
   111
		<div id="záhlaví">
franta-hg@77
   112
			<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
   113
		</div>
franta-hg@77
   114
	</xsl:template>
franta-hg@87
   115
franta-hg@77
   116
	<!--
franta-hg@77
   117
		Vloží zápatí (společné pro všechny stránky)
franta-hg@77
   118
		Pro potřeby CSS stylování má @id='zápatí'
franta-hg@77
   119
	-->
franta-hg@77
   120
	<xsl:template name="vložZápatí">
franta-hg@77
   121
		<div id="zápatí">
franta-hg@77
   122
			<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
   123
		</div>
franta-hg@77
   124
	</xsl:template>
franta-hg@51
   125
franta-hg@87
   126
	<!--
franta-hg@87
   127
		Vrací cestu v URL kódování, ale lomítka nekóduje
franta-hg@87
   128
	-->
franta-hg@87
   129
	<xsl:function name="m:escapuj-url-zachovej-lomítka" as="xs:string">
franta-hg@71
   130
		<xsl:param name="cesta"/>
franta-hg@71
   131
		<xsl:value-of select="replace(encode-for-uri($cesta), '%2F', '/')"/>
franta-hg@71
   132
	</xsl:function>
franta-hg@87
   133
franta-hg@71
   134
	<!--
franta-hg@71
   135
		Vrací obsah textového souboru ve vstupním adresáři.
franta-hg@71
   136
		Obvykle jako parametr předáváme atribut „src“.
franta-hg@71
   137
	-->
franta-hg@71
   138
	<xsl:function name="m:načti-textový-soubor" as="xs:string">
franta-hg@71
   139
		<xsl:param name="soubor"/>
franta-hg@71
   140
		<xsl:value-of select="unparsed-text(concat($vstup, $soubor))"/>
franta-hg@71
   141
	</xsl:function>
franta-hg@87
   142
franta-hg@51
   143
</xsl:stylesheet>
franta-hg@87
   144