view flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl @ 2515:532c590beb3e

Fixed problem with selecting the wrong map scale for printing. flys-client/trunk@4380 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 10 May 2012 09:49:08 +0000
parents 87ac5c532523
children 1b6270b00c91
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="html" encoding="UTF-8"/>

  <xsl:param name="project-uuid">de3f3307-3429-4ff9-8f43-3fb2fcf21b27</xsl:param>
  <xsl:param name="render-checkboxes" select="true()"/>
  <xsl:param name="callback"/>

  <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 &lt; 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) &lt; 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[&nbsp;]]></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[&nbsp;]]></xsl:text>
    </div>
  </xsl:template>

  <xsl:template match="event">
    <tr id="{@cid}">
      <xsl:if test="$render-checkboxes">
        <td>
          <input type="checkbox" name="{$project-uuid}:{@cid}" onclick="{$callback}"/>
        </td>
      </xsl:if>
      <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"
           style="font-size: 11pt;font-family:Arial;Verdana,sans-serif">
      <colgroup>
        <xsl:if test="$render-checkboxes">
            <col width="20px"/>
        </xsl:if>
        <col width="*"/>
        <col width="90px"/>
      </colgroup>
      <xsl:apply-templates/>
    </table>
  </xsl:template>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="text()"/>
  <xsl:template match="text()" mode="sectors"/>

</xsl:stylesheet>

http://dive4elements.wald.intevation.org