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