Show
Ignore:
Timestamp:
04/03/11 20:12:33 (13 years ago)
Author:
František Kučera <franta-hg@…>
Branch:
default
Message:

Ukázka uživatelského „makra“ a vkládání odkazů na CSS a JS soubory.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • šablona/stránka.xsl

    r8 r10  
    1414                doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"  
    1515                doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/> 
     16                 
     17        <xsl:param name="konfigurák"/> 
    1618         
    1719        <!-- Celý dokument: --> 
    1820        <xsl:template match="/"> 
     21                <xsl:variable name="konfigurace" select="document($konfigurák)"/> 
    1922                <html> 
    2023                        <head> 
    2124                                <title><xsl:value-of select="g:stránka/g:nadpis"/></title> 
    2225                                <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"/>                                 
    2429                        </head> 
    2530                        <body> 
     
    5055                </xsl:element> 
    5156    </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> 
    5283 
    5384</xsl:stylesheet>