Nové jmenné prostory: „s“ a „k“ místo „g“.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="2.0"
3 xmlns="http://www.w3.org/1999/xhtml"
4 xmlns:h="http://www.w3.org/1999/xhtml"
5 xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
6 xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace"
7 xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns:fn="http://www.w3.org/2005/xpath-functions"
10 xmlns:svg="http://www.w3.org/2000/svg"
11 xmlns:xs="http://www.w3.org/2001/XMLSchema"
12 exclude-result-prefixes="fn h s k xs m">
17 doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
18 doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
20 <!-- Vstupní adresář: -->
21 <xsl:param name="vstup" select="'../vstup/'"/>
22 <xsl:param name="vstupníPřípona" select="'.xml'"/>
23 <xsl:param name="výstupníPřípona" select="'.xhtml'"/>
24 <xsl:param name="vsuvkováPřípona" select="'.inc'"/>
25 <xsl:param name="podporaZaostalýchProhlížečů" select="false()" as="xs:boolean"/>
27 <!-- Celý dokument: -->
28 <xsl:template match="/">
29 <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/>
32 <xsl:if test="$podporaZaostalýchProhlížečů">
33 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
35 <title><xsl:value-of select="s:stránka/s:nadpis"/></title>
36 <link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
37 <link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/>
38 <xsl:apply-templates select="$konfigurace/k:web/k:js"/>
39 <xsl:apply-templates select="$konfigurace/k:web/k:css"/>
44 <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví', $vsuvkováPřípona)))/s:stránka/h:text/node()"/>
47 <h1><xsl:value-of select="s:stránka/s:nadpis"/></h1>
49 <xsl:for-each select="collection(concat('../vstup/?select=*', $vstupníPřípona))[s:stránka/s:pořadí]">
50 <xsl:sort select="empty(./s:stránka/s:pořadí)"/>
51 <xsl:sort select="./s:stránka/s:pořadí"/>
53 <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/>
54 <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/>
55 <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./s:stránka/s:nadpis"/></a>
60 <xsl:apply-templates select="s:stránka/h:text/node()"/>
64 <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí', $vsuvkováPřípona)))/s:stránka/h:text/node()"/>
71 <!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: -->
72 <xsl:template match="*">
73 <xsl:element name="{name()}">
74 <xsl:copy-of select="@*"/>
75 <xsl:apply-templates/>
79 <!-- Varování pro případ, že jsme v režimu podpory pro zaostalé prohlížeče -->
80 <xsl:template name="varováníRetardace">
81 <xsl:if test="$podporaZaostalýchProhlížečů">
83 Generátor byl spuštěn v režimu podpory zaostalých prohlížečů.
84 Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč,
85 jako je např. Firefox nebo Chromium (případně Opera či Safari).
90 <!-- Odkazy na JavaScript a kaskádové styly -->
91 <xsl:template match="k:web/k:js">
92 <script src="{text()}" type="text/javascript">
93 <xsl:call-template name="varováníRetardace"/>
96 <xsl:template match="k:web/k:css">
97 <link href="{text()}" type="text/css" rel="StyleSheet" />
101 Makro pro převod interních odkazů:
102 - doplnění správné přípony
105 <xsl:template match="m:a">
107 <xsl:copy-of select="@*"/>
108 <xsl:attribute name="href">
109 <xsl:value-of select="fn:encode-for-uri(concat(@href, $výstupníPřípona))"/>
111 <xsl:apply-templates/>
115 <!-- Ukázka vlastního „makra“: -->
116 <xsl:template match="m:měřák">
117 <xsl:variable name="hodnota" select="number(@hodnota)"/>
118 <xsl:variable name="šířkaGrafu" select="128"/>
120 <xsl:when test="$hodnota >= 0 and $hodnota <= 100">
121 <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;">
122 <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"><xsl:call-template name="varováníRetardace"/></div>
123 <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;">
124 <xsl:value-of select="@hodnota"/>/100
129 <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message>