1.1 --- a/šablona/stránka.xsl Sun Apr 03 18:44:35 2011 +0200
1.2 +++ b/šablona/stránka.xsl Sun Apr 03 20:12:33 2011 +0200
1.3 @@ -13,14 +13,19 @@
1.4 encoding="UTF-8"
1.5 doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
1.6 doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
1.7 +
1.8 + <xsl:param name="konfigurák"/>
1.9
1.10 <!-- Celý dokument: -->
1.11 <xsl:template match="/">
1.12 + <xsl:variable name="konfigurace" select="document($konfigurák)"/>
1.13 <html>
1.14 <head>
1.15 <title><xsl:value-of select="g:stránka/g:nadpis"/></title>
1.16 <link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
1.17 - <link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/>
1.18 + <link title="Novinky (RSS)" href="rss.xml" type="application/rss+xml" rel="alternate"/>
1.19 + <xsl:apply-templates select="$konfigurace/g:web/g:js"/>
1.20 + <xsl:apply-templates select="$konfigurace/g:web/g:css"/>
1.21 </head>
1.22 <body>
1.23 <xsl:apply-templates select="document(fn:encode-for-uri('../vstup/záhlaví.inc'))/g:stránka/h:text/node()"/>
1.24 @@ -49,5 +54,31 @@
1.25 <xsl:apply-templates/>
1.26 </xsl:element>
1.27 </xsl:template>
1.28 +
1.29 + <xsl:template match="g:web/g:js">
1.30 + <script src="{text()}" type="text/javascript" />
1.31 + </xsl:template>
1.32 + <xsl:template match="g:web/g:css">
1.33 + <link href="{text()}" type="text/css" rel="StyleSheet" />
1.34 + </xsl:template>
1.35 +
1.36 + <!-- Ukázka vlastního „makra“: -->
1.37 + <xsl:template match="g:měřák">
1.38 + <xsl:variable name="hodnota" select="number(@hodnota)"/>
1.39 + <xsl:variable name="šířkaGrafu" select="128"/>
1.40 + <xsl:choose>
1.41 + <xsl:when test="$hodnota >= 0 and $hodnota <= 100">
1.42 + <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;">
1.43 + <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"/>
1.44 + <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;">
1.45 + <xsl:value-of select="@hodnota"/>/100
1.46 + </p>
1.47 + </div>
1.48 + </xsl:when>
1.49 + <xsl:otherwise>
1.50 + <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message>
1.51 + </xsl:otherwise>
1.52 + </xsl:choose>
1.53 + </xsl:template>
1.54
1.55 </xsl:stylesheet>