author | František Kučera <franta-hg@frantovo.cz> |
Mon, 04 Apr 2011 00:24:56 +0200 | |
changeset 13 | d5e9c879663e |
parent 12 | 3719b121c3c4 |
child 15 | cfb2fc0ca242 |
permissions | -rw-r--r-- |
franta-hg@1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
franta-hg@1 | 2 |
<xsl:stylesheet version="2.0" |
franta-hg@1 | 3 |
xmlns="http://www.w3.org/1999/xhtml" |
franta-hg@2 | 4 |
xmlns:h="http://www.w3.org/1999/xhtml" |
franta-hg@2 | 5 |
xmlns:g="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/prostor" |
franta-hg@2 | 6 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
franta-hg@2 | 7 |
xmlns:fn="http://www.w3.org/2005/xpath-functions" |
franta-hg@5 | 8 |
xmlns:svg="http://www.w3.org/2000/svg" |
franta-hg@2 | 9 |
exclude-result-prefixes="fn h g"> |
franta-hg@2 | 10 |
<xsl:output |
franta-hg@2 | 11 |
method="xml" |
franta-hg@2 | 12 |
indent="yes" |
franta-hg@2 | 13 |
encoding="UTF-8" |
franta-hg@2 | 14 |
doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" |
franta-hg@2 | 15 |
doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/> |
franta-hg@11 | 16 |
|
franta-hg@11 | 17 |
<!-- Vstupní adresář: --> |
franta-hg@11 | 18 |
<xsl:param name="vstup" select="'../vstup/'"/> |
franta-hg@1 | 19 |
|
franta-hg@5 | 20 |
<!-- Celý dokument: --> |
franta-hg@1 | 21 |
<xsl:template match="/"> |
franta-hg@11 | 22 |
<xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/> |
franta-hg@1 | 23 |
<html> |
franta-hg@1 | 24 |
<head> |
franta-hg@6 | 25 |
<title><xsl:value-of select="g:stránka/g:nadpis"/></title> |
franta-hg@8 | 26 |
<link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/> |
franta-hg@10 | 27 |
<link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/> |
franta-hg@10 | 28 |
<xsl:apply-templates select="$konfigurace/g:web/g:js"/> |
franta-hg@10 | 29 |
<xsl:apply-templates select="$konfigurace/g:web/g:css"/> |
franta-hg@1 | 30 |
</head> |
franta-hg@1 | 31 |
<body> |
franta-hg@12 | 32 |
<div id="tělo"> |
franta-hg@12 | 33 |
<div id="záhlaví"> |
franta-hg@12 | 34 |
<xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'záhlaví.inc')))/g:stránka/h:text/node()"/> |
franta-hg@12 | 35 |
</div> |
franta-hg@12 | 36 |
<div id="vnitřek"> |
franta-hg@12 | 37 |
<h1><xsl:value-of select="g:stránka/g:nadpis"/></h1> |
franta-hg@12 | 38 |
<ul id="nabídka"> |
franta-hg@12 | 39 |
<xsl:for-each select="collection('../vstup/?select=*.xml')[g:stránka/g:pořadí]"> |
franta-hg@12 | 40 |
<xsl:sort select="empty(./g:stránka/g:pořadí)"/> |
franta-hg@12 | 41 |
<xsl:sort select="./g:stránka/g:pořadí"/> |
franta-hg@12 | 42 |
<li> |
franta-hg@12 | 43 |
<xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/> |
franta-hg@12 | 44 |
<xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, '.xml', '.xhtml')"/> |
franta-hg@12 | 45 |
<a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./g:stránka/g:nadpis"/></a> |
franta-hg@12 | 46 |
</li> |
franta-hg@12 | 47 |
</xsl:for-each> |
franta-hg@12 | 48 |
</ul> |
franta-hg@12 | 49 |
<div id="text"> |
franta-hg@12 | 50 |
<xsl:apply-templates select="g:stránka/h:text/node()"/> |
franta-hg@12 | 51 |
</div> |
franta-hg@12 | 52 |
</div> |
franta-hg@12 | 53 |
<div id="zápatí"> |
franta-hg@12 | 54 |
<xsl:apply-templates select="document(fn:encode-for-uri(concat($vstup, 'zápatí.inc')))/g:stránka/h:text/node()"/> |
franta-hg@12 | 55 |
</div> |
franta-hg@12 | 56 |
</div> |
franta-hg@1 | 57 |
</body> |
franta-hg@1 | 58 |
</html> |
franta-hg@1 | 59 |
</xsl:template> |
franta-hg@1 | 60 |
|
franta-hg@5 | 61 |
<!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: --> |
franta-hg@5 | 62 |
<xsl:template match="*"> |
franta-hg@5 | 63 |
<xsl:element name="{name()}"> |
franta-hg@5 | 64 |
<xsl:copy-of select="@*"/> |
franta-hg@5 | 65 |
<xsl:apply-templates/> |
franta-hg@5 | 66 |
</xsl:element> |
franta-hg@5 | 67 |
</xsl:template> |
franta-hg@10 | 68 |
|
franta-hg@11 | 69 |
<!-- Odkazy na JavaScript a kaskádové styly --> |
franta-hg@10 | 70 |
<xsl:template match="g:web/g:js"> |
franta-hg@10 | 71 |
<script src="{text()}" type="text/javascript" /> |
franta-hg@10 | 72 |
</xsl:template> |
franta-hg@10 | 73 |
<xsl:template match="g:web/g:css"> |
franta-hg@10 | 74 |
<link href="{text()}" type="text/css" rel="StyleSheet" /> |
franta-hg@10 | 75 |
</xsl:template> |
franta-hg@10 | 76 |
|
franta-hg@10 | 77 |
<!-- Ukázka vlastního „makra“: --> |
franta-hg@10 | 78 |
<xsl:template match="g:měřák"> |
franta-hg@10 | 79 |
<xsl:variable name="hodnota" select="number(@hodnota)"/> |
franta-hg@10 | 80 |
<xsl:variable name="šířkaGrafu" select="128"/> |
franta-hg@10 | 81 |
<xsl:choose> |
franta-hg@10 | 82 |
<xsl:when test="$hodnota >= 0 and $hodnota <= 100"> |
franta-hg@10 | 83 |
<div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;"> |
franta-hg@10 | 84 |
<div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"/> |
franta-hg@10 | 85 |
<p style="margin: 0px; font-size: 12px; position: relative; top: -15px;"> |
franta-hg@10 | 86 |
<xsl:value-of select="@hodnota"/>/100 |
franta-hg@10 | 87 |
</p> |
franta-hg@10 | 88 |
</div> |
franta-hg@10 | 89 |
</xsl:when> |
franta-hg@10 | 90 |
<xsl:otherwise> |
franta-hg@10 | 91 |
<xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message> |
franta-hg@10 | 92 |
</xsl:otherwise> |
franta-hg@10 | 93 |
</xsl:choose> |
franta-hg@10 | 94 |
</xsl:template> |
franta-hg@1 | 95 |
|
franta-hg@1 | 96 |
</xsl:stylesheet> |