[1] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
| 2 | <xsl:stylesheet version="2.0" |
---|
| 3 | xmlns="http://www.w3.org/1999/xhtml" |
---|
[2] | 4 | xmlns:h="http://www.w3.org/1999/xhtml" |
---|
[18] | 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" |
---|
[17] | 7 | xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro" |
---|
[2] | 8 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
| 9 | xmlns:fn="http://www.w3.org/2005/xpath-functions" |
---|
[5] | 10 | xmlns:svg="http://www.w3.org/2000/svg" |
---|
[15] | 11 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
[18] | 12 | exclude-result-prefixes="fn h s k xs m"> |
---|
[2] | 13 | <xsl:output |
---|
| 14 | method="xml" |
---|
| 15 | indent="yes" |
---|
| 16 | encoding="UTF-8" |
---|
| 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"/> |
---|
[11] | 19 | |
---|
| 20 | <!-- Vstupní adresář: --> |
---|
| 21 | <xsl:param name="vstup" select="'../vstup/'"/> |
---|
[15] | 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"/> |
---|
[1] | 26 | |
---|
[5] | 27 | <!-- Celý dokument: --> |
---|
[1] | 28 | <xsl:template match="/"> |
---|
[11] | 29 | <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/> |
---|
[1] | 30 | <html> |
---|
| 31 | <head> |
---|
[16] | 32 | <xsl:if test="$podporaZaostalýchProhlížečů"> |
---|
| 33 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> |
---|
| 34 | </xsl:if> |
---|
[18] | 35 | <title><xsl:value-of select="s:stránka/s:nadpis"/></title> |
---|
[8] | 36 | <link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/> |
---|
[10] | 37 | <link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/> |
---|
[18] | 38 | <xsl:apply-templates select="$konfigurace/k:web/k:js"/> |
---|
| 39 | <xsl:apply-templates select="$konfigurace/k:web/k:css"/> |
---|
[1] | 40 | </head> |
---|
| 41 | <body> |
---|
[12] | 42 | <div id="tělo"> |
---|
| 43 | <div id="záhlaví"> |
---|
[18] | 44 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví', $vsuvkováPřípona)))/s:stránka/h:text/node()"/> |
---|
[12] | 45 | </div> |
---|
| 46 | <div id="vnitřek"> |
---|
[18] | 47 | <h1><xsl:value-of select="s:stránka/s:nadpis"/></h1> |
---|
[12] | 48 | <ul id="nabídka"> |
---|
[18] | 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í"/> |
---|
[12] | 52 | <li> |
---|
| 53 | <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/> |
---|
[15] | 54 | <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, $vstupníPřípona, $výstupníPřípona)"/> |
---|
[18] | 55 | <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./s:stránka/s:nadpis"/></a> |
---|
[12] | 56 | </li> |
---|
| 57 | </xsl:for-each> |
---|
| 58 | </ul> |
---|
| 59 | <div id="text"> |
---|
[18] | 60 | <xsl:apply-templates select="s:stránka/h:text/node()"/> |
---|
[12] | 61 | </div> |
---|
| 62 | </div> |
---|
| 63 | <div id="zápatí"> |
---|
[18] | 64 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí', $vsuvkováPřípona)))/s:stránka/h:text/node()"/> |
---|
[12] | 65 | </div> |
---|
| 66 | </div> |
---|
[1] | 67 | </body> |
---|
| 68 | </html> |
---|
| 69 | </xsl:template> |
---|
| 70 | |
---|
[5] | 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/> |
---|
| 76 | </xsl:element> |
---|
| 77 | </xsl:template> |
---|
[10] | 78 | |
---|
[18] | 79 | <!-- Varování pro případ, že jsme v režimu podpory pro zaostalé prohlížeče --> |
---|
[15] | 80 | <xsl:template name="varováníRetardace"> |
---|
| 81 | <xsl:if test="$podporaZaostalýchProhlížečů"> |
---|
| 82 | <xsl:comment> |
---|
| 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). |
---|
| 86 | </xsl:comment> |
---|
| 87 | </xsl:if> |
---|
[18] | 88 | </xsl:template> |
---|
| 89 | |
---|
| 90 | <!-- Odkazy na JavaScript a kaskádové styly --> |
---|
| 91 | <xsl:template match="k:web/k:js"> |
---|
[15] | 92 | <script src="{text()}" type="text/javascript"> |
---|
| 93 | <xsl:call-template name="varováníRetardace"/> |
---|
| 94 | </script> |
---|
[10] | 95 | </xsl:template> |
---|
[18] | 96 | <xsl:template match="k:web/k:css"> |
---|
[10] | 97 | <link href="{text()}" type="text/css" rel="StyleSheet" /> |
---|
| 98 | </xsl:template> |
---|
[17] | 99 | |
---|
| 100 | <!-- |
---|
| 101 | Makro pro převod interních odkazů: |
---|
| 102 | - doplnění správné přípony |
---|
| 103 | - URL kódování znaků |
---|
| 104 | --> |
---|
| 105 | <xsl:template match="m:a"> |
---|
| 106 | <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))"/> |
---|
| 110 | </xsl:attribute> |
---|
| 111 | <xsl:apply-templates/> |
---|
| 112 | </a> |
---|
| 113 | </xsl:template> |
---|
[10] | 114 | |
---|
| 115 | <!-- Ukázka vlastního „makra“: --> |
---|
[18] | 116 | <xsl:template match="m:měřák"> |
---|
[10] | 117 | <xsl:variable name="hodnota" select="number(@hodnota)"/> |
---|
| 118 | <xsl:variable name="šířkaGrafu" select="128"/> |
---|
| 119 | <xsl:choose> |
---|
| 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;"> |
---|
[16] | 122 | <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"><xsl:call-template name="varováníRetardace"/></div> |
---|
[10] | 123 | <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;"> |
---|
| 124 | <xsl:value-of select="@hodnota"/>/100 |
---|
| 125 | </p> |
---|
| 126 | </div> |
---|
| 127 | </xsl:when> |
---|
| 128 | <xsl:otherwise> |
---|
| 129 | <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message> |
---|
| 130 | </xsl:otherwise> |
---|
| 131 | </xsl:choose> |
---|
| 132 | </xsl:template> |
---|
[1] | 133 | |
---|
| 134 | </xsl:stylesheet> |
---|