šablona/stránka-společné.xsl
author František Kučera <franta-hg@frantovo.cz>
Sun, 08 Jan 2012 17:26:24 +0100
changeset 78 7e478bfa5694
parent 77 2f11f0ba6f13
child 87 25dec6931f18
permissions -rw-r--r--
Definice uživatelských maker nebudeme kopírovat do výstupu, drobnosti.
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@77
    43
	<!-- 
franta-hg@77
    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@51
    52
    
franta-hg@77
    53
	<!-- 
franta-hg@77
    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@77
    65
	
franta-hg@77
    66
	<!-- 
franta-hg@77
    67
		Odkazy na JavaScript a kaskádové styly 
franta-hg@77
    68
	-->    
franta-hg@77
    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@77
    77
    
franta-hg@77
    78
    <!--
franta-hg@77
    79
    	Vloží nečíslovaný seznam obsahující hlavní nabídku webu (seznam stránek)
franta-hg@77
    80
    	Pro potřeby CSS stylování má nabídka @id='nabídka'
franta-hg@77
    81
    -->
franta-hg@77
    82
	<xsl:template name="vložNabídku">
franta-hg@77
    83
		<ul id="nabídka">
franta-hg@77
    84
			<xsl:for-each select="collection(concat('./', $vstup ,'/?select=*', $vstupníPřípona))[s:stránka/s:pořadí]">
franta-hg@77
    85
				<xsl:sort select="empty(./s:stránka/s:pořadí)"/>
franta-hg@77
    86
				<xsl:sort select="./s:stránka/s:pořadí"/>
franta-hg@77
    87
				<li>
franta-hg@77
    88
					<xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/>
franta-hg@77
    89
					<xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/>
franta-hg@77
    90
					<a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./s:stránka/s:nadpis"/></a>
franta-hg@77
    91
				</li>
franta-hg@77
    92
			</xsl:for-each>
franta-hg@77
    93
		</ul>
franta-hg@77
    94
	</xsl:template>
franta-hg@77
    95
	
franta-hg@77
    96
	<!--
franta-hg@77
    97
		Vloží záhlaví (společné pro všechny stránky)
franta-hg@77
    98
		Pro potřeby CSS stylování má @id='záhlaví'
franta-hg@77
    99
	-->
franta-hg@77
   100
	<xsl:template name="vložZáhlaví">
franta-hg@77
   101
		<div id="záhlaví">
franta-hg@77
   102
			<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
   103
		</div>
franta-hg@77
   104
	</xsl:template>
franta-hg@77
   105
	
franta-hg@77
   106
	<!--
franta-hg@77
   107
		Vloží zápatí (společné pro všechny stránky)
franta-hg@77
   108
		Pro potřeby CSS stylování má @id='zápatí'
franta-hg@77
   109
	-->
franta-hg@77
   110
	<xsl:template name="vložZápatí">
franta-hg@77
   111
		<div id="zápatí">
franta-hg@77
   112
			<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
   113
		</div>
franta-hg@77
   114
	</xsl:template>
franta-hg@51
   115
franta-hg@77
   116
    <!--
franta-hg@77
   117
    	Vrací cestu v URL kódování, ale lomítka nekóduje
franta-hg@77
   118
    -->
franta-hg@71
   119
    <xsl:function name="m:escapuj-url-zachovej-lomítka" as="xs:string">
franta-hg@71
   120
		<xsl:param name="cesta"/>
franta-hg@71
   121
		<xsl:value-of select="replace(encode-for-uri($cesta), '%2F', '/')"/>
franta-hg@71
   122
	</xsl:function>
franta-hg@71
   123
	
franta-hg@71
   124
	<!--
franta-hg@71
   125
		Vrací obsah textového souboru ve vstupním adresáři.
franta-hg@71
   126
		Obvykle jako parametr předáváme atribut „src“.
franta-hg@71
   127
	-->
franta-hg@71
   128
	<xsl:function name="m:načti-textový-soubor" as="xs:string">
franta-hg@71
   129
		<xsl:param name="soubor"/>
franta-hg@71
   130
		<xsl:value-of select="unparsed-text(concat($vstup, $soubor))"/>
franta-hg@71
   131
	</xsl:function>
franta-hg@71
   132
    
franta-hg@51
   133
</xsl:stylesheet>