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