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 exclude-result-prefixes="fn h g">
14 doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
15 doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
17 <!-- Vstupní adresář: -->
18 <xsl:param name="vstup" select="'../vstup/'"/>
20 <!-- Celý dokument: -->
21 <xsl:template match="/">
22 <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/>
25 <title><xsl:value-of select="g:stránka/g:nadpis"/></title>
26 <link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
27 <link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/>
28 <xsl:apply-templates select="$konfigurace/g:web/g:js"/>
29 <xsl:apply-templates select="$konfigurace/g:web/g:css"/>
32 <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví.inc')))/g:stránka/h:text/node()"/>
33 <h1><xsl:value-of select="g:stránka/g:nadpis"/></h1>
34 <xsl:apply-templates select="g:stránka/h:text/node()"/>
36 <xsl:for-each select="collection('../vstup/?select=*.xml')[g:stránka/g:pořadí]">
37 <xsl:sort select="empty(./g:stránka/g:pořadí)"/>
38 <xsl:sort select="./g:stránka/g:pořadí"/>
40 <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/>
41 <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, '.xml', '.xhtml')"/>
42 <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./g:stránka/g:nadpis"/></a>
46 <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí.inc')))/g:stránka/h:text/node()"/>
51 <!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: -->
52 <xsl:template match="*">
53 <xsl:element name="{name()}">
54 <xsl:copy-of select="@*"/>
55 <xsl:apply-templates/>
59 <!-- Odkazy na JavaScript a kaskádové styly -->
60 <xsl:template match="g:web/g:js">
61 <script src="{text()}" type="text/javascript" />
63 <xsl:template match="g:web/g:css">
64 <link href="{text()}" type="text/css" rel="StyleSheet" />
67 <!-- Ukázka vlastního „makra“: -->
68 <xsl:template match="g:měřák">
69 <xsl:variable name="hodnota" select="number(@hodnota)"/>
70 <xsl:variable name="šířkaGrafu" select="128"/>
72 <xsl:when test="$hodnota >= 0 and $hodnota <= 100">
73 <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;">
74 <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"/>
75 <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;">
76 <xsl:value-of select="@hodnota"/>/100
81 <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message>