<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="ISO-8859-1" indent="yes"
    media-type="image/svg+xml" omit-xml-declaration="yes" />
  <xsl:strip-space elements="*" />

  <xsl:template match="tourGuide">
    <!-- Linke obere Ecke, Breite und Höhe des Anzeigebereiches. Alle
      Y-Koordinaten negativ, um die nordliche Breite hinzubekommen. -->
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -10 10 10">

      <xsl:for-each select="destination/node">
        <!-- Trick: Mit einer Variable hantieren, weil der folgende Vergleich
          sonst Unsinn macht. -->
        <xsl:variable name="cmp" select="@name" />
        <!-- Nur, wenn überhaupt ein passendes Element <imp> existiert. -->
        <xsl:if test="../../tourist/imp[@name=$cmp]">

          <circle fill="rgb(100%, 33%, 0%)" cx="{@lat}" cy="-{@long}"
            r="0.{../../tourist/imp[@name=$cmp]/@value}" />

          <!-- Das war die Kurzversion. Hier die lange, die genau das Selbe
            erzeugt:
          <xsl:element name="circle">
            <xsl:attribute name="fill">rgb(100%, 33%, 0%)</xsl:attribute>
            <xsl:attribute name="cx"><xsl:value-of
              select="@lat" /></xsl:attribute>
            <xsl:attribute name="cy">-<xsl:value-of
              select="@long" /></xsl:attribute>
            <xsl:attribute name="r">0.<xsl:value-of
              select="../../tourist/imp[@name=$cmp]/@value" /></xsl:attribute>
          </xsl:element>
          -->

        </xsl:if>
      </xsl:for-each>

      <circle fill="black"
        cx="{tourist/start/@lat}" cy="-{tourist/start/@long}" r="0.25" />
      <circle fill="none" stroke="black" stroke-width="0.1"
        cx="{tourist/end/@lat}" cy="-{tourist/end/@long}" r="0.2" />

      <!-- Hier ist die Kurzversion nicht möglich, weil ein Attribut in einer
        Schleife aus mehreren Teilen zusammengesetzt werden muss. -->
      <xsl:element name="polyline">
        <xsl:attribute name="fill">none</xsl:attribute>
        <xsl:attribute name="stroke">#CCC</xsl:attribute>
        <xsl:attribute name="stroke-width">0.1</xsl:attribute>
        <xsl:attribute name="points">
          <xsl:for-each select="destination/node">
            <xsl:value-of select="@lat" />,-<xsl:value-of select="@long" />
            <!-- Leerzeichen erzwingen, sonst schlägt strip-space zu. -->
            <xsl:text> </xsl:text>
          </xsl:for-each>
        </xsl:attribute>
      </xsl:element>

    </svg>
  </xsl:template>

</xsl:stylesheet>