šablona/stránka.xsl
changeset 10 4e70453a027f
parent 8 ad0ee12d13fd
child 11 78a8dd1eeb2b
equal deleted inserted replaced
9:71275159d985 10:4e70453a027f
    11 		method="xml" 
    11 		method="xml" 
    12 		indent="yes" 
    12 		indent="yes" 
    13 		encoding="UTF-8"		
    13 		encoding="UTF-8"		
    14 		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
    14 		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
    15 		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
    15 		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
       
    16 		
       
    17 	<xsl:param name="konfigurák"/>
    16 	
    18 	
    17 	<!-- Celý dokument: -->
    19 	<!-- Celý dokument: -->
    18 	<xsl:template match="/">
    20 	<xsl:template match="/">
       
    21 		<xsl:variable name="konfigurace" select="document($konfigurák)"/>
    19 		<html>
    22 		<html>
    20 			<head>
    23 			<head>
    21 				<title><xsl:value-of select="g:stránka/g:nadpis"/></title>
    24 				<title><xsl:value-of select="g:stránka/g:nadpis"/></title>
    22 				<link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
    25 				<link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
    23 				<link title="Novinky (RSS)"  href="rss.xml"  type="application/rss+xml"  rel="alternate"/>				
    26 				<link title="Novinky (RSS)"  href="rss.xml"  type="application/rss+xml"  rel="alternate"/>
       
    27 				<xsl:apply-templates select="$konfigurace/g:web/g:js"/>
       
    28 				<xsl:apply-templates select="$konfigurace/g:web/g:css"/>				
    24 			</head>
    29 			</head>
    25 			<body>
    30 			<body>
    26 				<xsl:apply-templates select="document(fn:encode-for-uri('../vstup/záhlaví.inc'))/g:stránka/h:text/node()"/>			
    31 				<xsl:apply-templates select="document(fn:encode-for-uri('../vstup/záhlaví.inc'))/g:stránka/h:text/node()"/>			
    27 				<h1><xsl:value-of select="g:stránka/g:nadpis"/></h1>
    32 				<h1><xsl:value-of select="g:stránka/g:nadpis"/></h1>
    28 				<xsl:apply-templates select="g:stránka/h:text/node()"/>
    33 				<xsl:apply-templates select="g:stránka/h:text/node()"/>
    47 		<xsl:element name="{name()}">
    52 		<xsl:element name="{name()}">
    48 			<xsl:copy-of select="@*"/>
    53 			<xsl:copy-of select="@*"/>
    49 			<xsl:apply-templates/>
    54 			<xsl:apply-templates/>
    50 		</xsl:element>
    55 		</xsl:element>
    51     </xsl:template>
    56     </xsl:template>
       
    57     
       
    58     <xsl:template match="g:web/g:js">
       
    59     	<script src="{text()}" type="text/javascript" />
       
    60     </xsl:template>
       
    61     <xsl:template match="g:web/g:css">
       
    62     	<link href="{text()}" type="text/css" rel="StyleSheet" />
       
    63     </xsl:template>
       
    64     
       
    65     <!-- Ukázka vlastního „makra“: -->
       
    66     <xsl:template match="g:měřák">
       
    67     	<xsl:variable name="hodnota" select="number(@hodnota)"/>
       
    68     	<xsl:variable name="šířkaGrafu" select="128"/>
       
    69 		<xsl:choose>			
       
    70 			<xsl:when test="$hodnota &gt;= 0 and $hodnota &lt;= 100">				
       
    71 				<div style="border: 1px solid black; width: {$šířkaGrafu}px; height: 16px; padding: 0px; text-align: center; background-color: #cfc;">			
       
    72 					<div style="margin: 0px; background-color: #A4E666; width: {@hodnota*$šířkaGrafu div 100}px; height: 16px;"/>
       
    73 					<p style="margin: 0px; font-size: 12px; position: relative; top: -15px;">
       
    74 						<xsl:value-of select="@hodnota"/>/100
       
    75 					</p>	
       
    76 				</div>
       
    77 			</xsl:when>
       
    78 			<xsl:otherwise>
       
    79 				<xsl:message terminate="yes">Hodnota měřáku musí být nejméně 0 a nejvíce 100 (udává procenta).</xsl:message>
       
    80 			</xsl:otherwise>
       
    81 		</xsl:choose>
       
    82 	</xsl:template>
    52 
    83 
    53 </xsl:stylesheet>
    84 </xsl:stylesheet>