view gnv-artifacts/contrib/palette2qgis.xsl @ 522:c896282c2601

Issue 156 solved. Added width, height and points as parameter to svg and pdf output mode. Width and height have an effact on the width and height of the export, points is a boolean property which enables/disables the drawing of data points. gnv-artifacts/trunk@616 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 25 Jan 2010 09:18:31 +0000
parents a8f6ca59b26e
children f953c9a559d8
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <!--
    palette2qgis.xsl
    ================
    Transforms palette XML files into QGIS style files. Useful
    to display "Horizontalschnitte" with the right colors.

    Tested with Quantum GIS 1.4.0-Enceladus.

    usage: xsltproc palette2qgis.xsl palette.xml > style.qml

    Author: Sascha L. Teichmann (sascha.teichmann@intevation.de)
    -->
  <xsl:output
       method="xml"
       doctype-system="PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'"/>

  <xsl:template name="hex2number">
    <xsl:param name="hex"/>
    <xsl:choose>
        <xsl:when test="string-length($hex) &lt; 1">
            <xsl:value-of select="0"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:variable
                name="x" 
                select="translate(substring($hex, string-length($hex), 1), 'ABCDEF', 'abcdef')"/>
            <xsl:variable name="last">
              <xsl:choose>
                <xsl:when test="$x = 'a'">10</xsl:when>
                <xsl:when test="$x = 'b'">11</xsl:when>
                <xsl:when test="$x = 'c'">12</xsl:when>
                <xsl:when test="$x = 'd'">13</xsl:when>
                <xsl:when test="$x = 'e'">14</xsl:when>
                <xsl:when test="$x = 'f'">15</xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$x"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:variable name="rest">
              <xsl:call-template name="hex2number">
                 <xsl:with-param
                      name="hex"
                      select="substring($hex, 1, string-length($hex)-1)"/>
              </xsl:call-template>
            </xsl:variable>
            <xsl:value-of select="number($last) + 16*$rest"/>
        </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="/ranges/range">
    <symbol>
      <lowervalue><xsl:value-of select="@index"/></lowervalue>
      <uppervalue><xsl:value-of select="@index"/></uppervalue>
      <label><xsl:value-of select="@description"/></label>
      <pointsymbol>hard:circle</pointsymbol>
      <pointsize>2</pointsize>
      <pointsizeunits>pixels</pointsizeunits>
      <rotationclassificationfieldname/>
      <scaleclassificationfieldname/>
      <symbolfieldname/>
      <outlinecolor red="0" blue="0" green="0"/>
      <outlinestyle>NoPen</outlinestyle>
      <outlinewidth>0.26</outlinewidth>
      <xsl:variable name="rgb">
        <xsl:call-template name="hex2number">
          <xsl:with-param name="hex" select="substring(@rgb, 2)"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="red" select="floor(($rgb div (256*256)) mod 256)"/>
      <xsl:variable name="green" select="floor(($rgb div 256) mod 256)"/>
      <xsl:variable name="blue" select="floor($rgb mod 256)"/>
      <fillcolor red="{$red}" blue="{$blue}" green="{$green}"/>
      <fillpattern>SolidPattern</fillpattern>
      <texturepath null="1"/>
    </symbol>
  </xsl:template>
  <xsl:template match="/">
    <qgis version="1.4.0-Enceladus" minimumScale="1" maximumScale="1e+08" minLabelScale="1" maxLabelScale="1e+08" hasScaleBasedVisibilityFlag="0" scaleBasedLabelVisibilityFlag="0">
      <transparencyLevelInt>255</transparencyLevelInt>
      <classificationattribute>CLASS</classificationattribute>
      <symbol>
        <lowervalue null="1"/>
        <uppervalue null="1"/>
        <label>Andere</label>
        <pointsymbol>hard:circle</pointsymbol>
        <pointsize>2</pointsize>
        <pointsizeunits>pixels</pointsizeunits>
        <rotationclassificationfieldname/>
        <scaleclassificationfieldname/>
        <symbolfieldname/>
        <outlinecolor red="0" blue="0" green="0"/>
        <outlinestyle>DashDotDotLine</outlinestyle>
        <outlinewidth>0.26</outlinewidth>
        <fillcolor red="59" blue="81" green="179"/>
        <fillpattern>SolidPattern</fillpattern>
        <texturepath null="1"/>
      </symbol>
      <uniquevalue>
        <classificationfield>CLASS</classificationfield>
        <xsl:apply-templates/>
      </uniquevalue>
      <edittypes>
        <edittype type="0" name="CLASS"/>
        <edittype type="0" name="DATE"/>
        <edittype type="0" name="LAYER"/>
        <edittype type="0" name="PARAMETER"/>
      </edittypes>
      <editform/>
      <editforminit/>
      <displayfield>PARAMETER</displayfield>
      <label>0</label>
      <attributeactions/>
      <labelattributes>
        <label fieldname="" text="Beschriftung"/>
        <family fieldname="" name="Sans Serif"/>
        <size fieldname="" units="pt" value="12"/>
        <bold fieldname="" on="0"/>
        <italic fieldname="" on="0"/>
        <underline fieldname="" on="0"/>
        <color fieldname="" red="0" blue="0" green="0"/>
        <x fieldname=""/>
        <y fieldname=""/>
        <offset x="0" y="0" units="pt" yfieldname="" xfieldname=""/>
        <angle fieldname="" value="0" auto="0"/>
        <alignment fieldname="" value="center"/>
        <buffercolor fieldname="" red="255" blue="255" green="255"/>
        <buffersize fieldname="" units="pt" value="1"/>
        <bufferenabled fieldname="" on=""/>
        <multilineenabled fieldname="" on=""/>
      </labelattributes>
    </qgis>
  </xsl:template>
  <xsl:template match="text()"/>
</xsl:stylesheet>

http://dive4elements.wald.intevation.org