Mercurial > dive4elements > river
changeset 3429:3353672f9ba2
FixA: XSL overview transform renders the names of the gauges into the head line.
flys-artifacts/trunk@5088 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 20 Jul 2012 13:51:36 +0000 |
parents | 842b7b635701 |
children | 278b5508567e |
files | flys-artifacts/ChangeLog flys-artifacts/contrib/fixoverview2html.xsl |
diffstat | 2 files changed, 120 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Jul 20 10:22:38 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jul 20 13:51:36 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-20 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * contrib/fixoverview2html.xsl: Render the names of the gauges into + the header line. Full name and spread is displayed as a tooltip. + 2012-07-20 Ingo Weinzierl <ingo@intevation.de> * doc/conf/artifacts/minfo.xml: Use SQPeriodSelect state for the input of
--- a/flys-artifacts/contrib/fixoverview2html.xsl Fri Jul 20 10:22:38 2012 +0000 +++ b/flys-artifacts/contrib/fixoverview2html.xsl Fri Jul 20 13:51:36 2012 +0000 @@ -23,9 +23,9 @@ </xsl:if> </xsl:template> - <xsl:variable name="events-min"> + <xsl:variable name="global-min"> <xsl:choose> - <xsl:when test="count(/fixings/events/event/sector) > 0"> + <xsl:when test="count(/fixings/events/event) > 0"> <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from"> <xsl:sort data-type="number" select="."/> </xsl:apply-templates> @@ -36,9 +36,9 @@ </xsl:choose> </xsl:variable> - <xsl:variable name="events-max"> + <xsl:variable name="global-max"> <xsl:choose> - <xsl:when test="count(/fixings/events/event/sector) > 0"> + <xsl:when test="count(/fixings/events/event) > 0"> <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to"> <xsl:sort data-type="number" select="."/> </xsl:apply-templates> @@ -51,48 +51,97 @@ <xsl:template name="percent"> <xsl:param name="sector"/> - <xsl:variable name="rfrom" select="number($events-min)"/> - <xsl:variable name="rto" select="number($events-max)"/> - <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:variable name="start"> + <xsl:choose> + <xsl:when test="number($sector/@from) < $global-min"> + <xsl:value-of select="$global-min"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="number($sector/@from)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="end"> + <xsl:choose> + <xsl:when test="number($sector/@to) > $global-max"> + <xsl:value-of select="$global-max"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="number($sector/@to)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$end < $start"> + <xsl:value-of select="number(0)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="100.0 * (($end - $start) div ($global-max - $global-min))"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="emit-gap-gauge"> + <xsl:param name="gauge"/> + <xsl:call-template name="internal-emit-gap"> + <xsl:with-param name="sector" select="$gauge"/> + <xsl:with-param name="preds" select="$gauge/preceding-sibling::gauge"/> + </xsl:call-template> </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:call-template name="internal-emit-gap"> + <xsl:with-param name="sector" select="$sector"/> + <xsl:with-param name="preds" select="$sector/preceding-sibling::sector"/> + </xsl:call-template> + </xsl:template> + + <xsl:template name="internal-emit-gap"> + <xsl:param name="sector"/> + <xsl:param name="preds"/> + + <xsl:variable name="start"> <xsl:choose> - <xsl:when test="$num-preds < 1"> - <xsl:variable name="rfrom" select="number($events-min)"/> - <xsl:value-of select="number($sector/@from) - $rfrom"/> + <xsl:when test="number($sector/@from) < $global-min"> + <xsl:value-of select="$global-min"/> </xsl:when> <xsl:otherwise> - <xsl:variable name="bend" select="number($preds[last()]/@to)"/> - <xsl:value-of select="number($sector/@from) - $bend"/> + <xsl:value-of select="$sector/@from"/> </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($events-min)"/> - <xsl:variable name="rto" select="number($events-max)"/> - <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:if test="$start < $global-max"> + <xsl:variable name="num-preds" select="count($preds)"/> + <xsl:variable name="prev-end"> + <xsl:choose> + <xsl:when test="count($preds) < 1"> + <xsl:value-of select="$global-min"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="number($preds[last()]/@to)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:if test="$prev-end < $global-max"> + <xsl:variable name="gap-len" select="$start - $prev-end"/> + <xsl:if test="$gap-len > 0.005"> + <div> + <xsl:attribute name="style"> + <xsl:text>width:</xsl:text> + <xsl:value-of select="100.0 * ($gap-len div ($global-max - $global-min))"/> + <xsl:text>%;float:left</xsl:text> + </xsl:attribute> + <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> + </div> + </xsl:if> + </xsl:if> + </xsl:if> </xsl:template> <xsl:template match="sector" mode="sectors"> @@ -149,6 +198,35 @@ </tr> </xsl:template> + <xsl:template match="gauge" mode="gauges"> + <xsl:call-template name="emit-gap-gauge"> + <xsl:with-param name="gauge" select="."/> + </xsl:call-template> + <div> + <xsl:attribute name="style"> + <xsl:text>overflow:hidden;background:</xsl:text> + <xsl:choose> + <xsl:when test="(count(preceding::*) mod 2) = 0">#ada96e</xsl:when> + <xsl:otherwise>gray</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:value-of select="@name"/> + <xsl:text>: km </xsl:text> + <xsl:value-of select="@from"/> + <xsl:text> - </xsl:text> + <xsl:value-of select="@to"/> + </xsl:attribute> + <nobr><xsl:value-of select="@name"/></nobr> + </div> + </xsl:template> + <xsl:template match="events"> <table width="97%" border="1" cellspacing="0" cellpadding="0" style="font-size: 10pt;font-family:Arial;Verdana,sans-serif"> @@ -163,7 +241,7 @@ <xsl:if test="$render-checkboxes"> <th> </th> </xsl:if> - <th>km <xsl:value-of select="$events-min"/> - <xsl:value-of select="$events-max"/></th> + <th><xsl:apply-templates mode="gauges" select="/fixings/gauges"/></th> <th>Ereignis</th> </tr> <xsl:apply-templates/> @@ -219,5 +297,6 @@ <xsl:template match="text()"/> <xsl:template match="text()" mode="sectors"/> + <xsl:template match="text()" mode="gauges"/> </xsl:stylesheet>