# HG changeset patch # User František Kučera <franta-hg@frantovo.cz> # Date 1304187654 -7200 # Node ID b81b96475fe03ff0a1dcc63dd2b899adce727dba # Parent 45e41566f8a65c2512fd81817281a013af8dd9bf Vyčlenění uživatelských maker do samostatného souboru: #8 diff -r 45e41566f8a6 -r b81b96475fe0 vstup/makra.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vstup/makra.xsl Sat Apr 30 20:20:54 2011 +0200 @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="2.0" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://www.w3.org/1999/xhtml" + xmlns:s="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" + xmlns:k="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/konfigurace" + xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:fn="http://www.w3.org/2005/xpath-functions" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="fn h s k m xs"> + + <!-- Ukázka vlastního „makra“: --> + <xsl:template match="m:měřák"> + <xsl:variable name="hodnota" select="number(@hodnota)"/> + <xsl:variable name="šířkaGrafu" select="128"/> + <xsl:choose> + <xsl:when test="$hodnota >= 0 and $hodnota <= 100"> + <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;"> + <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"><xsl:call-template name="varováníRetardace"/></div> + <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;"> + <xsl:value-of select="@hodnota"/>/100 + </p> + </div> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file diff -r 45e41566f8a6 -r b81b96475fe0 šablona/makra.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/šablona/makra.xsl Sat Apr 30 20:20:54 2011 +0200 @@ -0,0 +1,1 @@ +../vstup/makra.xsl \ No newline at end of file diff -r 45e41566f8a6 -r b81b96475fe0 šablona/stránka.xsl --- a/šablona/stránka.xsl Sat Apr 30 19:34:55 2011 +0200 +++ b/šablona/stránka.xsl Sat Apr 30 20:20:54 2011 +0200 @@ -9,21 +9,22 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xs="http://www.w3.org/2001/XMLSchema" - exclude-result-prefixes="fn h s k xs m"> + exclude-result-prefixes="fn h s k m xs"> <xsl:output method="xml" indent="yes" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/> - - <!-- Vstupní adresář: --> + <xsl:param name="vstup" select="'../vstup/'"/> <xsl:param name="vstupníPřípona" select="'.xml'"/> <xsl:param name="výstupníPřípona" select="'.xhtml'"/> <xsl:param name="vsuvkováPřípona" select="'.inc'"/> <xsl:param name="podporaZaostalýchProhlížečů" select="false()" as="xs:boolean"/> + <xsl:include href="makra.xsl"/> + <!-- Celý dokument: --> <xsl:template match="/"> <xsl:variable name="konfigurace" select="document(concat($vstup, 'web.conf'))"/> @@ -111,24 +112,5 @@ <xsl:apply-templates/> </a> </xsl:template> - - <!-- Ukázka vlastního „makra“: --> - <xsl:template match="m:měřák"> - <xsl:variable name="hodnota" select="number(@hodnota)"/> - <xsl:variable name="šířkaGrafu" select="128"/> - <xsl:choose> - <xsl:when test="$hodnota >= 0 and $hodnota <= 100"> - <div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;"> - <div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"><xsl:call-template name="varováníRetardace"/></div> - <p style="margin: 0px; font-size: 12px; position: relative; top: -15px;"> - <xsl:value-of select="@hodnota"/>/100 - </p> - </div> - </xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:template> </xsl:stylesheet>