sascha@2565: <?xml version="1.0" encoding="UTF-8"?> sascha@2565: <xsl:stylesheet sascha@2565: version="1.0" sascha@2565: xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> sascha@2565: sascha@2632: <xsl:output method="xml" encoding="UTF-8" sascha@2632: doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" sascha@2632: doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/> sascha@2632: sascha@2632: <xsl:param name="project-uuid">de3f3307-3429-4ff9-8f43-3fb2fcf21b27</xsl:param> sascha@2632: <xsl:param name="render-checkboxes" select="true()"/> sascha@3427: <xsl:param name="callback"/> sascha@3427: sascha@3431: <xsl:param name="locale">de</xsl:param> sascha@3431: sascha@3431: <xsl:decimal-format name="de" decimal-separator=',' grouping-separator='.'/> sascha@3431: <xsl:decimal-format name="en" decimal-separator='.' grouping-separator=','/> sascha@3431: sascha@3432: <!-- XXX: This kind of i18n is cheesy. sascha@3432: It should be better done in an external resource. --> sascha@3432: sascha@3431: <xsl:variable name="km-pattern"> sascha@3431: <xsl:choose> sascha@3431: <xsl:when test="$locale = 'de'">0,##</xsl:when> sascha@3431: <xsl:otherwise>0.##</xsl:otherwise> sascha@3431: </xsl:choose> sascha@3431: </xsl:variable> sascha@3431: sascha@3432: <xsl:variable name="i18n-event"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">Ereignis</xsl:when> sascha@3432: <xsl:otherwise>Event</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-legend"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">Legende</xsl:when> sascha@3432: <xsl:otherwise>Caption</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-color"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">Farbe</xsl:when> sascha@3432: <xsl:otherwise>Color</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-meaning"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">Bedeutung</xsl:when> sascha@3432: <xsl:otherwise>Meaning</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-around-mnq"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">um MNQ</xsl:when> sascha@3432: <xsl:otherwise>around MNQ</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-around-mq"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">um MQ</xsl:when> sascha@3432: <xsl:otherwise>around MQ</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-around-mhq"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">um MHQ</xsl:when> sascha@3432: <xsl:otherwise>around MHQ</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3432: sascha@3432: <xsl:variable name="i18n-above-hq5"> sascha@3432: <xsl:choose> sascha@3432: <xsl:when test="$locale = 'de'">über HQ5</xsl:when> sascha@3432: <xsl:otherwise>above HQ5</xsl:otherwise> sascha@3432: </xsl:choose> sascha@3432: </xsl:variable> sascha@3431: sascha@3431: <!-- TODO: Format dates according locale. --> sascha@3431: sascha@3427: <xsl:template match="@*" mode="min"> sascha@3427: <xsl:if test="position() = 1"> sascha@3427: <xsl:value-of select="number(.)"/> sascha@3427: </xsl:if> sascha@3427: </xsl:template> sascha@3427: sascha@3427: <xsl:template match="@*" mode="max"> sascha@3427: <xsl:if test="position() = last()"> sascha@3427: <xsl:value-of select="number(.)"/> sascha@3427: </xsl:if> sascha@3427: </xsl:template> sascha@3427: sascha@3429: <xsl:variable name="global-min"> sascha@3427: <xsl:choose> sascha@3431: <xsl:when test="count(/fixings/events/event/sector) > 0"> sascha@3427: <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from"> sascha@3427: <xsl:sort data-type="number" select="."/> sascha@3427: </xsl:apply-templates> sascha@3427: </xsl:when> sascha@3427: <xsl:otherwise> sascha@3427: <xsl:value-of select="number(/fixings/river/@from)"/> sascha@3427: </xsl:otherwise> sascha@3427: </xsl:choose> sascha@3427: </xsl:variable> sascha@3427: sascha@3429: <xsl:variable name="global-max"> sascha@3427: <xsl:choose> sascha@3431: <xsl:when test="count(/fixings/events/event/sector) > 0"> sascha@3427: <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to"> sascha@3427: <xsl:sort data-type="number" select="."/> sascha@3427: </xsl:apply-templates> sascha@3427: </xsl:when> sascha@3427: <xsl:otherwise> sascha@3427: <xsl:value-of select="number(/fixings/river/@to)"/> sascha@3427: </xsl:otherwise> sascha@3427: </xsl:choose> sascha@3427: </xsl:variable> sascha@2565: sascha@2565: <xsl:template name="percent"> sascha@2565: <xsl:param name="sector"/> sascha@2565: sascha@3429: <xsl:variable name="start"> sascha@3429: <xsl:choose> sascha@3429: <xsl:when test="number($sector/@from) < $global-min"> sascha@3429: <xsl:value-of select="$global-min"/> sascha@3429: </xsl:when> sascha@3429: <xsl:otherwise> sascha@3429: <xsl:value-of select="number($sector/@from)"/> sascha@3429: </xsl:otherwise> sascha@3429: </xsl:choose> sascha@3429: </xsl:variable> sascha@3429: sascha@3429: <xsl:variable name="end"> sascha@3429: <xsl:choose> sascha@3429: <xsl:when test="number($sector/@to) > $global-max"> sascha@3429: <xsl:value-of select="$global-max"/> sascha@3429: </xsl:when> sascha@3429: <xsl:otherwise> sascha@3429: <xsl:value-of select="number($sector/@to)"/> sascha@3429: </xsl:otherwise> sascha@3429: </xsl:choose> sascha@3429: </xsl:variable> sascha@3429: sascha@3429: <xsl:choose> sascha@3429: <xsl:when test="$end < $start"> sascha@3429: <xsl:value-of select="number(0)"/> sascha@3429: </xsl:when> sascha@3429: <xsl:otherwise> sascha@3429: <xsl:value-of select="100.0 * (($end - $start) div ($global-max - $global-min))"/> sascha@3429: </xsl:otherwise> sascha@3429: </xsl:choose> sascha@3429: </xsl:template> sascha@3429: sascha@3429: <xsl:template name="emit-gap-gauge"> sascha@3429: <xsl:param name="gauge"/> sascha@3429: <xsl:call-template name="internal-emit-gap"> sascha@3429: <xsl:with-param name="sector" select="$gauge"/> sascha@3429: <xsl:with-param name="preds" select="$gauge/preceding-sibling::gauge"/> sascha@3429: </xsl:call-template> sascha@2565: </xsl:template> sascha@2565: sascha@2565: <xsl:template name="emit-gap"> sascha@2565: <xsl:param name="sector"/> sascha@3429: <xsl:call-template name="internal-emit-gap"> sascha@3429: <xsl:with-param name="sector" select="$sector"/> sascha@3429: <xsl:with-param name="preds" select="$sector/preceding-sibling::sector"/> sascha@3429: </xsl:call-template> sascha@3429: </xsl:template> sascha@3429: sascha@3429: <xsl:template name="internal-emit-gap"> sascha@3429: <xsl:param name="sector"/> sascha@3429: <xsl:param name="preds"/> sascha@3429: sascha@3429: <xsl:variable name="start"> sascha@2565: <xsl:choose> sascha@3429: <xsl:when test="number($sector/@from) < $global-min"> sascha@3429: <xsl:value-of select="$global-min"/> sascha@2565: </xsl:when> sascha@2565: <xsl:otherwise> sascha@3429: <xsl:value-of select="$sector/@from"/> sascha@2565: </xsl:otherwise> sascha@2565: </xsl:choose> sascha@2565: </xsl:variable> sascha@3429: sascha@3429: <xsl:if test="$start < $global-max"> sascha@3429: <xsl:variable name="num-preds" select="count($preds)"/> sascha@3429: <xsl:variable name="prev-end"> sascha@3429: <xsl:choose> sascha@3429: <xsl:when test="count($preds) < 1"> sascha@3429: <xsl:value-of select="$global-min"/> sascha@3429: </xsl:when> sascha@3429: <xsl:otherwise> sascha@3429: <xsl:value-of select="number($preds[last()]/@to)"/> sascha@3429: </xsl:otherwise> sascha@3429: </xsl:choose> sascha@3429: </xsl:variable> sascha@3429: sascha@3429: <xsl:if test="$prev-end < $global-max"> sascha@3429: <xsl:variable name="gap-len" select="$start - $prev-end"/> sascha@3429: <xsl:if test="$gap-len > 0.005"> sascha@3429: <div> sascha@3429: <xsl:attribute name="style"> sascha@3429: <xsl:text>width:</xsl:text> sascha@3429: <xsl:value-of select="100.0 * ($gap-len div ($global-max - $global-min))"/> sascha@3429: <xsl:text>%;float:left</xsl:text> sascha@3429: </xsl:attribute> sascha@3429: <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> sascha@3429: </div> sascha@3429: </xsl:if> sascha@3429: </xsl:if> sascha@3429: </xsl:if> sascha@2565: </xsl:template> sascha@2565: sascha@2565: <xsl:template match="sector" mode="sectors"> sascha@2565: <xsl:call-template name="emit-gap"> sascha@2565: <xsl:with-param name="sector" select="."/> sascha@2565: </xsl:call-template> sascha@2565: <div> sascha@2565: <xsl:attribute name="style"> sascha@2565: <xsl:text>background:</xsl:text> sascha@2565: <xsl:choose> sascha@2565: <xsl:when test="@class = '0'">green</xsl:when> sascha@2565: <xsl:when test="@class = '1'">blue</xsl:when> sascha@2565: <xsl:when test="@class = '2'">magenta</xsl:when> sascha@2565: <xsl:when test="@class = '3'">red</xsl:when> sascha@2565: <xsl:otherwise>black</xsl:otherwise> sascha@2565: </xsl:choose> sascha@2565: <xsl:text>;width:</xsl:text> sascha@2565: <xsl:call-template name="percent"> sascha@2565: <xsl:with-param name="sector" select="."/> sascha@2565: </xsl:call-template> sascha@2565: <xsl:text>%</xsl:text> sascha@2565: <xsl:text>;float:left</xsl:text> sascha@2565: </xsl:attribute> sascha@2565: <xsl:attribute name="title"> sascha@2565: <xsl:text>km </xsl:text> sascha@3431: <xsl:value-of select="format-number(@from, $km-pattern, $locale)"/> sascha@2565: <xsl:text> - </xsl:text> sascha@3431: <xsl:value-of select="format-number(@to, $km-pattern, $locale)"/> sascha@3427: <xsl:choose> sascha@3431: <xsl:when test="@class = '0'"> / Q <xsl:value-of select="$i18n-around-mnq"/></xsl:when> sascha@3431: <xsl:when test="@class = '1'"> / Q <xsl:value-of select="$i18n-around-mq"/></xsl:when> sascha@3431: <xsl:when test="@class = '2'"> / Q <xsl:value-of select="$i18n-around-mhq"/></xsl:when> sascha@3431: <xsl:when test="@class = '3'"> / Q <xsl:value-of select="$i18n-above-hq5"/></xsl:when> sascha@3427: </xsl:choose> sascha@2565: </xsl:attribute> sascha@2565: <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> sascha@2565: </div> sascha@2565: </xsl:template> sascha@2565: sascha@2565: <xsl:template match="event"> sascha@3427: <tr id="{@cid}"> sascha@2632: <xsl:if test="$render-checkboxes"> sascha@2632: <td> sascha@3427: <input type="checkbox" name="{$project-uuid}:{@cid}" checked="true" onclick="{$callback}"/> sascha@2632: </td> sascha@2632: </xsl:if> sascha@2565: <td> sascha@2565: <xsl:apply-templates mode="sectors"/> sascha@2565: </td> sascha@2565: <td align="center"> sascha@2707: <xsl:attribute name="title"><xsl:value-of select="@description"/></xsl:attribute> sascha@2565: <xsl:value-of select="@date"/> sascha@2565: </td> sascha@2565: </tr> sascha@2565: </xsl:template> sascha@2565: sascha@3429: <xsl:template match="gauge" mode="gauges"> sascha@3429: <xsl:call-template name="emit-gap-gauge"> sascha@3429: <xsl:with-param name="gauge" select="."/> sascha@3429: </xsl:call-template> sascha@3429: <div> sascha@3433: <xsl:variable name="start"> sascha@3433: <xsl:choose> sascha@3433: <xsl:when test="number(@from) < $global-min"> sascha@3433: <xsl:value-of select="$global-min"/> sascha@3433: </xsl:when> sascha@3433: <xsl:otherwise> sascha@3433: <xsl:value-of select="number(@from)"/> sascha@3433: </xsl:otherwise> sascha@3433: </xsl:choose> sascha@3433: </xsl:variable> sascha@3433: sascha@3433: <xsl:variable name="end"> sascha@3433: <xsl:choose> sascha@3433: <xsl:when test="number(@to) > $global-max"> sascha@3433: <xsl:value-of select="$global-max"/> sascha@3433: </xsl:when> sascha@3433: <xsl:otherwise> sascha@3433: <xsl:value-of select="number(@to)"/> sascha@3433: </xsl:otherwise> sascha@3433: </xsl:choose> sascha@3433: </xsl:variable> sascha@3433: sascha@3429: <xsl:attribute name="style"> sascha@3429: <xsl:text>overflow:hidden;background:</xsl:text> sascha@3429: <xsl:choose> sascha@3433: <xsl:when test="(count(preceding::*) mod 2) = 0">#ada96e</xsl:when> sascha@3431: <xsl:otherwise>silver</xsl:otherwise> sascha@3429: </xsl:choose> sascha@3429: <xsl:text>;width:</xsl:text> sascha@3429: <xsl:call-template name="percent"> sascha@3429: <xsl:with-param name="sector" select="."/> sascha@3429: </xsl:call-template> sascha@3429: <xsl:text>%</xsl:text> sascha@3429: <xsl:text>;float:left</xsl:text> sascha@3429: </xsl:attribute> sascha@3429: <xsl:attribute name="title"> sascha@3429: <xsl:value-of select="@name"/> sascha@3429: <xsl:text>: km </xsl:text> sascha@3433: <xsl:value-of select="format-number($start, $km-pattern, $locale)"/> sascha@3429: <xsl:text> - </xsl:text> sascha@3433: <xsl:value-of select="format-number($end, $km-pattern, $locale)"/> sascha@3429: </xsl:attribute> sascha@3429: <nobr><xsl:value-of select="@name"/></nobr> sascha@3429: </div> sascha@3429: </xsl:template> sascha@3429: sascha@2565: <xsl:template match="events"> sascha@3427: <table width="97%" border="1" cellspacing="0" cellpadding="0" sascha@3427: style="font-size: 10pt;font-family:Arial;Verdana,sans-serif"> sascha@2565: <colgroup> sascha@2632: <xsl:if test="$render-checkboxes"> sascha@3427: <col width="20px"/> sascha@2632: </xsl:if> sascha@2632: <col width="*"/> sascha@3427: <col width="75px"/> sascha@2565: </colgroup> sascha@3427: <tr> sascha@3427: <xsl:if test="$render-checkboxes"> sascha@3427: <th> </th> sascha@3427: </xsl:if> sascha@3429: <th><xsl:apply-templates mode="gauges" select="/fixings/gauges"/></th> sascha@3431: <th><xsl:value-of select="$i18n-event"/></th> sascha@3427: </tr> sascha@2565: <xsl:apply-templates/> sascha@2565: </table> sascha@2565: </xsl:template> sascha@2565: sascha@2565: <xsl:template match="/"> sascha@2565: <html> sascha@2565: <head> sascha@2565: <title>Fixierungen:</title> sascha@2565: </head> sascha@2565: <body> sascha@2565: <xsl:apply-templates/> sascha@3427: <hr/> sascha@3427: <table border="1" cellspacing="0" cellpadding="0"> sascha@3431: <caption><xsl:value-of select="$i18n-legend"/></caption> sascha@3427: <tr> sascha@3431: <th><xsl:value-of select="$i18n-color"/></th> sascha@3431: <th colspan="2"><xsl:value-of select="$i18n-meaning"/></th> sascha@3427: </tr> sascha@3427: <xsl:if test="count(/fixings/events/event/sector[@class = '0']) > 0"> sascha@3427: <tr> sascha@3427: <td style="background: green"> </td> sascha@3431: <td><xsl:value-of select="$i18n-around-mnq"/></td> sascha@3427: <td>Q ∈ [0, (MNQ+MQ)/2)</td> sascha@3427: </tr> sascha@3427: </xsl:if> sascha@3427: <xsl:if test="count(/fixings/events/event/sector[@class = '1']) > 0"> sascha@3427: <tr> sascha@3427: <td style="background: blue"> </td> sascha@3431: <td><xsl:value-of select="$i18n-around-mq"/></td> sascha@3427: <td>Q ∈ [(MNQ+MQ)/2, (MQ+MHQ)/2)</td> sascha@3427: </tr> sascha@3427: </xsl:if> sascha@3427: <xsl:if test="count(/fixings/events/event/sector[@class = '2']) > 0"> sascha@3427: <tr> sascha@3427: <td style="background: magenta"> </td> sascha@3431: <td><xsl:value-of select="$i18n-around-mhq"/></td> sascha@3427: <td>Q ∈ [(MQ+MHQ)/2, HQ5)</td> sascha@3427: </tr> sascha@3427: </xsl:if> sascha@3427: <xsl:if test="count(/fixings/events/event/sector[@class = '3']) > 0"> sascha@3427: <tr> sascha@3427: <td style="background: red"> </td> sascha@3431: <td><xsl:value-of select="$i18n-above-hq5"/></td> sascha@3427: <td>Q ∈ [HQ5, ∞)</td> sascha@3427: </tr> sascha@3427: </xsl:if> sascha@3427: </table> sascha@2565: </body> sascha@2565: </html> sascha@2565: </xsl:template> sascha@2565: sascha@2565: <xsl:template match="text()"/> sascha@2565: <xsl:template match="text()" mode="sectors"/> sascha@3429: <xsl:template match="text()" mode="gauges"/> sascha@2565: sascha@2565: </xsl:stylesheet>