view flys-artifacts/contrib/fixoverview2html.xsl @ 2656:f1dcd5f94ffa

Parse more theme properties for linelabels. flys-artifacts/trunk@4327 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 02 May 2012 15:09:04 +0000
parents 7d163c2c6e6d
children d6e32ae72da6
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"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>

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

  <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>
      <xsl:if test="$render-checkboxes">
        <td>
          <input type="checkbox" name="{$project-uuid}:{@cid}"/>
        </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="1em"/>
        </xsl:if>
        <col width="*"/>
        <col width="11em"/>
      </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>

http://dive4elements.wald.intevation.org