Mercurial > dive4elements > river
view flys-artifacts/contrib/fixoverview2html.xsl @ 2607:247f3e98a14b
Abjusted services to new hierachy.
flys-artifacts/trunk@4189 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 Apr 2012 11:15:13 +0000 |
parents | 72f77b2210c2 |
children | 7d163c2c6e6d |
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8"/> <xsl:template name="percent"> <xsl:param name="sector"/> <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> <xsl:variable name="rto" select="number(/fixings/river/@to)"/> <xsl:variable name="rlength" select="$rto - $rfrom"/> <xsl:variable name="sfrom" select="number($sector/@from)"/> <xsl:variable name="sto" select="number($sector/@to)"/> <xsl:variable name="slength" select="$sto - $sfrom"/> <xsl:value-of select="100.0 * ($slength div $rlength)"/> </xsl:template> <xsl:template name="emit-gap"> <xsl:param name="sector"/> <xsl:variable name="preds" select="$sector/preceding-sibling::sector"/> <xsl:variable name="num-preds" select="count($preds)"/> <xsl:variable name="glength"> <xsl:choose> <xsl:when test="$num-preds < 1"> <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> <xsl:value-of select="number($sector/@from) - $rfrom"/> </xsl:when> <xsl:otherwise> <xsl:variable name="bend" select="number($preds[last()]/@to)"/> <xsl:value-of select="number($sector/@from) - $bend"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="number($glength) < 0.05 "/> <xsl:otherwise> <div> <xsl:attribute name="style"> <xsl:text>width:</xsl:text> <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> <xsl:variable name="rto" select="number(/fixings/river/@to)"/> <xsl:variable name="rlength" select="$rto - $rfrom"/> <xsl:value-of select="100.0 * ($glength div $rlength)"/> <xsl:text>%;float:left</xsl:text> </xsl:attribute> <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> </div> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="sector" mode="sectors"> <xsl:call-template name="emit-gap"> <xsl:with-param name="sector" select="."/> </xsl:call-template> <div> <xsl:attribute name="style"> <xsl:text>background:</xsl:text> <xsl:choose> <xsl:when test="@class = '0'">green</xsl:when> <xsl:when test="@class = '1'">blue</xsl:when> <xsl:when test="@class = '2'">magenta</xsl:when> <xsl:when test="@class = '3'">red</xsl:when> <xsl:otherwise>black</xsl:otherwise> </xsl:choose> <xsl:text>;width:</xsl:text> <xsl:call-template name="percent"> <xsl:with-param name="sector" select="."/> </xsl:call-template> <xsl:text>%</xsl:text> <xsl:text>;float:left</xsl:text> </xsl:attribute> <xsl:attribute name="title"> <xsl:text>km </xsl:text> <xsl:value-of select="@from"/> <xsl:text> - </xsl:text> <xsl:value-of select="@to"/> </xsl:attribute> <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> </div> </xsl:template> <xsl:template match="event"> <tr> <td> <xsl:apply-templates mode="sectors"/> </td> <td align="center"> <xsl:attribute name="title"><xsl:value-of select="@name"/></xsl:attribute> <xsl:value-of select="@date"/> </td> </tr> </xsl:template> <xsl:template match="events"> <table width="95%" border="1" cellspacing="0" cellpadding="0"> <colgroup> <col width="85%"/> <col width="15%"/> </colgroup> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match="/"> <html> <head> <title>Fixierungen:</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="text()"/> <xsl:template match="text()" mode="sectors"/> </xsl:stylesheet>