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:g="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/prostor" |
---|
6 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
7 | xmlns:fn="http://www.w3.org/2005/xpath-functions" |
---|
8 | xmlns:svg="http://www.w3.org/2000/svg" |
---|
9 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
10 | exclude-result-prefixes="fn h g xs"> |
---|
11 | <xsl:output |
---|
12 | method="xml" |
---|
13 | indent="yes" |
---|
14 | encoding="UTF-8" |
---|
15 | doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" |
---|
16 | doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/> |
---|
17 | |
---|
18 | <!-- Vstupní adresář: --> |
---|
19 | <xsl:param name="vstup" select="'../vstup/'"/> |
---|
20 | <xsl:param name="vstupníPřípona" select="'.xml'"/> |
---|
21 | <xsl:param name="výstupníPřípona" select="'.xhtml'"/> |
---|
22 | <xsl:param name="vsuvkováPřípona" select="'.inc'"/> |
---|
23 | <xsl:param name="podporaZaostalýchProhlížečů" select="false()" as="xs:boolean"/> |
---|
24 | |
---|
25 | <!-- Celý dokument: --> |
---|
26 | <xsl:template match="/"> |
---|
27 | <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/> |
---|
28 | <html> |
---|
29 | <head> |
---|
30 | <xsl:if test="$podporaZaostalýchProhlížečů"> |
---|
31 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> |
---|
32 | </xsl:if> |
---|
33 | <title><xsl:value-of select="g:stránka/g:nadpis"/></title> |
---|
34 | <link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/> |
---|
35 | <link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/> |
---|
36 | <xsl:apply-templates select="$konfigurace/g:web/g:js"/> |
---|
37 | <xsl:apply-templates select="$konfigurace/g:web/g:css"/> |
---|
38 | </head> |
---|
39 | <body> |
---|
40 | <div id="tělo"> |
---|
41 | <div id="záhlaví"> |
---|
42 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví', $vsuvkováPřípona)))/g:stránka/h:text/node()"/> |
---|
43 | </div> |
---|
44 | <div id="vnitřek"> |
---|
45 | <h1><xsl:value-of select="g:stránka/g:nadpis"/></h1> |
---|
46 | <ul id="nabídka"> |
---|
47 | <xsl:for-each select="collection(concat('../vstup/?select=*', $vstupníPřípona))[g:stránka/g:pořadí]"> |
---|
48 | <xsl:sort select="empty(./g:stránka/g:pořadí)"/> |
---|
49 | <xsl:sort select="./g:stránka/g:pořadí"/> |
---|
50 | <li> |
---|
51 | <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/> |
---|
52 | <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/> |
---|
53 | <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./g:stránka/g:nadpis"/></a> |
---|
54 | </li> |
---|
55 | </xsl:for-each> |
---|
56 | </ul> |
---|
57 | <div id="text"> |
---|
58 | <xsl:apply-templates select="g:stránka/h:text/node()"/> |
---|
59 | </div> |
---|
60 | </div> |
---|
61 | <div id="zápatí"> |
---|
62 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí', $vsuvkováPřípona)))/g:stránka/h:text/node()"/> |
---|
63 | </div> |
---|
64 | </div> |
---|
65 | </body> |
---|
66 | </html> |
---|
67 | </xsl:template> |
---|
68 | |
---|
69 | <!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: --> |
---|
70 | <xsl:template match="*"> |
---|
71 | <xsl:element name="{name()}"> |
---|
72 | <xsl:copy-of select="@*"/> |
---|
73 | <xsl:apply-templates/> |
---|
74 | </xsl:element> |
---|
75 | </xsl:template> |
---|
76 | |
---|
77 | <!-- Odkazy na JavaScript a kaskádové styly --> |
---|
78 | <xsl:template name="varováníRetardace"> |
---|
79 | <xsl:if test="$podporaZaostalýchProhlížečů"> |
---|
80 | <xsl:comment> |
---|
81 | Generátor byl spuštěn v režimu podpory zaostalých prohlížečů. |
---|
82 | Uživatelům doporučujeme upgrade na skutečný WWW prohlížeč, |
---|
83 | jako je např. Firefox nebo Chromium (případně Opera či Safari). |
---|
84 | </xsl:comment> |
---|
85 | </xsl:if> |
---|
86 | </xsl:template> |
---|
87 | <xsl:template match="g:web/g:js"> |
---|
88 | <script src="{text()}" type="text/javascript"> |
---|
89 | <xsl:call-template name="varováníRetardace"/> |
---|
90 | </script> |
---|
91 | </xsl:template> |
---|
92 | <xsl:template match="g:web/g:css"> |
---|
93 | <link href="{text()}" type="text/css" rel="StyleSheet" /> |
---|
94 | </xsl:template> |
---|
95 | |
---|
96 | <!-- Ukázka vlastního „makra“: --> |
---|
97 | <xsl:template match="g:měřák"> |
---|
98 | <xsl:variable name="hodnota" select="number(@hodnota)"/> |
---|
99 | <xsl:variable name="šířkaGrafu" select="128"/> |
---|
100 | <xsl:choose> |
---|
101 | <xsl:when test="$hodnota >= 0 and $hodnota <= 100"> |
---|
102 | <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;"> |
---|
103 | <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"><xsl:call-template name="varováníRetardace"/></div> |
---|
104 | <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;"> |
---|
105 | <xsl:value-of select="@hodnota"/>/100 |
---|
106 | </p> |
---|
107 | </div> |
---|
108 | </xsl:when> |
---|
109 | <xsl:otherwise> |
---|
110 | <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message> |
---|
111 | </xsl:otherwise> |
---|
112 | </xsl:choose> |
---|
113 | </xsl:template> |
---|
114 | |
---|
115 | </xsl:stylesheet> |
---|