| 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"> |
|---|
| 10 | <xsl:output |
|---|
| 11 | method="xml" |
|---|
| 12 | indent="yes" |
|---|
| 13 | encoding="UTF-8" |
|---|
| 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"/> |
|---|
| 16 | |
|---|
| 17 | <!-- Vstupní adresář: --> |
|---|
| 18 | <xsl:param name="vstup" select="'../vstup/'"/> |
|---|
| 19 | |
|---|
| 20 | <!-- Celý dokument: --> |
|---|
| 21 | <xsl:template match="/"> |
|---|
| 22 | <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/> |
|---|
| 23 | <html> |
|---|
| 24 | <head> |
|---|
| 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"/> |
|---|
| 30 | </head> |
|---|
| 31 | <body> |
|---|
| 32 | <div id="tělo"> |
|---|
| 33 | <div id="záhlaví"> |
|---|
| 34 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví.inc')))/g:stránka/h:text/node()"/> |
|---|
| 35 | </div> |
|---|
| 36 | <div id="vnitřek"> |
|---|
| 37 | <h1><xsl:value-of select="g:stránka/g:nadpis"/></h1> |
|---|
| 38 | <ul id="nabídka"> |
|---|
| 39 | <xsl:for-each select="collection('../vstup/?select=*.xml')[g:stránka/g:pořadí]"> |
|---|
| 40 | <xsl:sort select="empty(./g:stránka/g:pořadí)"/> |
|---|
| 41 | <xsl:sort select="./g:stránka/g:pořadí"/> |
|---|
| 42 | <li> |
|---|
| 43 | <xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/> |
|---|
| 44 | <xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, '.xml', '.xhtml')"/> |
|---|
| 45 | <a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./g:stránka/g:nadpis"/></a> |
|---|
| 46 | </li> |
|---|
| 47 | </xsl:for-each> |
|---|
| 48 | </ul> |
|---|
| 49 | <div id="text"> |
|---|
| 50 | <xsl:apply-templates select="g:stránka/h:text/node()"/> |
|---|
| 51 | </div> |
|---|
| 52 | </div> |
|---|
| 53 | <div id="zápatí"> |
|---|
| 54 | <xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí.inc')))/g:stránka/h:text/node()"/> |
|---|
| 55 | </div> |
|---|
| 56 | </div> |
|---|
| 57 | </body> |
|---|
| 58 | </html> |
|---|
| 59 | </xsl:template> |
|---|
| 60 | |
|---|
| 61 | <!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: --> |
|---|
| 62 | <xsl:template match="*"> |
|---|
| 63 | <xsl:element name="{name()}"> |
|---|
| 64 | <xsl:copy-of select="@*"/> |
|---|
| 65 | <xsl:apply-templates/> |
|---|
| 66 | </xsl:element> |
|---|
| 67 | </xsl:template> |
|---|
| 68 | |
|---|
| 69 | <!-- Odkazy na JavaScript a kaskádové styly --> |
|---|
| 70 | <xsl:template match="g:web/g:js"> |
|---|
| 71 | <script src="{text()}" type="text/javascript" /> |
|---|
| 72 | </xsl:template> |
|---|
| 73 | <xsl:template match="g:web/g:css"> |
|---|
| 74 | <link href="{text()}" type="text/css" rel="StyleSheet" /> |
|---|
| 75 | </xsl:template> |
|---|
| 76 | |
|---|
| 77 | <!-- Ukázka vlastního „makra“: --> |
|---|
| 78 | <xsl:template match="g:měřák"> |
|---|
| 79 | <xsl:variable name="hodnota" select="number(@hodnota)"/> |
|---|
| 80 | <xsl:variable name="šířkaGrafu" select="128"/> |
|---|
| 81 | <xsl:choose> |
|---|
| 82 | <xsl:when test="$hodnota >= 0 and $hodnota <= 100"> |
|---|
| 83 | <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;"> |
|---|
| 84 | <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"/> |
|---|
| 85 | <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;"> |
|---|
| 86 | <xsl:value-of select="@hodnota"/>/100 |
|---|
| 87 | </p> |
|---|
| 88 | </div> |
|---|
| 89 | </xsl:when> |
|---|
| 90 | <xsl:otherwise> |
|---|
| 91 | <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message> |
|---|
| 92 | </xsl:otherwise> |
|---|
| 93 | </xsl:choose> |
|---|
| 94 | </xsl:template> |
|---|
| 95 | |
|---|
| 96 | </xsl:stylesheet> |
|---|