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