comparison gnv-artifacts/contrib/palette2qgis.xsl @ 1119:7c4f81f74c47

merged gnv-artifacts
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:00 +0200
parents f953c9a559d8
children
comparison
equal deleted inserted replaced
1027:fca4b5eb8d2f 1119:7c4f81f74c47
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
4 <!--
5 palette2qgis.xsl
6 ================
7
8 Copyright (c) 2010 by Intevation GmbH
9
10 This program is free software under the LGPL (>=v2.1)
11 Read the file LGPL.txt coming with the software for details
12 or visit http://www.gnu.org/licenses/ if it does not exist.
13
14 Transforms palette XML files into QGIS style files. Useful
15 to display "Horizontalschnitte" with the right colors.
16
17 Tested with Quantum GIS 1.4.0-Enceladus.
18
19 usage: xsltproc palette2qgis.xsl palette.xml > style.qml
20
21 Author: Sascha L. Teichmann (sascha.teichmann@intevation.de)
22 -->
23 <xsl:output
24 method="xml"
25 doctype-system="PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'"/>
26
27 <xsl:template name="hex2number">
28 <xsl:param name="hex"/>
29 <xsl:choose>
30 <xsl:when test="string-length($hex) &lt; 1">
31 <xsl:value-of select="0"/>
32 </xsl:when>
33 <xsl:otherwise>
34 <xsl:variable
35 name="x"
36 select="translate(substring($hex, string-length($hex), 1), 'ABCDEF', 'abcdef')"/>
37 <xsl:variable name="last">
38 <xsl:choose>
39 <xsl:when test="$x = 'a'">10</xsl:when>
40 <xsl:when test="$x = 'b'">11</xsl:when>
41 <xsl:when test="$x = 'c'">12</xsl:when>
42 <xsl:when test="$x = 'd'">13</xsl:when>
43 <xsl:when test="$x = 'e'">14</xsl:when>
44 <xsl:when test="$x = 'f'">15</xsl:when>
45 <xsl:otherwise>
46 <xsl:value-of select="$x"/>
47 </xsl:otherwise>
48 </xsl:choose>
49 </xsl:variable>
50 <xsl:variable name="rest">
51 <xsl:call-template name="hex2number">
52 <xsl:with-param
53 name="hex"
54 select="substring($hex, 1, string-length($hex)-1)"/>
55 </xsl:call-template>
56 </xsl:variable>
57 <xsl:value-of select="number($last) + 16*$rest"/>
58 </xsl:otherwise>
59 </xsl:choose>
60 </xsl:template>
61
62 <xsl:template match="/ranges/range">
63 <symbol>
64 <lowervalue><xsl:value-of select="@index"/></lowervalue>
65 <uppervalue><xsl:value-of select="@index"/></uppervalue>
66 <label><xsl:value-of select="@description"/></label>
67 <pointsymbol>hard:circle</pointsymbol>
68 <pointsize>2</pointsize>
69 <pointsizeunits>pixels</pointsizeunits>
70 <rotationclassificationfieldname/>
71 <scaleclassificationfieldname/>
72 <symbolfieldname/>
73 <outlinecolor red="0" blue="0" green="0"/>
74 <outlinestyle>NoPen</outlinestyle>
75 <outlinewidth>0.26</outlinewidth>
76 <xsl:variable name="rgb">
77 <xsl:call-template name="hex2number">
78 <xsl:with-param name="hex" select="substring(@rgb, 2)"/>
79 </xsl:call-template>
80 </xsl:variable>
81 <xsl:variable name="red" select="floor(($rgb div (256*256)) mod 256)"/>
82 <xsl:variable name="green" select="floor(($rgb div 256) mod 256)"/>
83 <xsl:variable name="blue" select="floor($rgb mod 256)"/>
84 <fillcolor red="{$red}" blue="{$blue}" green="{$green}"/>
85 <fillpattern>SolidPattern</fillpattern>
86 <texturepath null="1"/>
87 </symbol>
88 </xsl:template>
89 <xsl:template match="/">
90 <qgis version="1.4.0-Enceladus" minimumScale="1" maximumScale="1e+08" minLabelScale="1" maxLabelScale="1e+08" hasScaleBasedVisibilityFlag="0" scaleBasedLabelVisibilityFlag="0">
91 <transparencyLevelInt>255</transparencyLevelInt>
92 <classificationattribute>CLASS</classificationattribute>
93 <symbol>
94 <lowervalue null="1"/>
95 <uppervalue null="1"/>
96 <label>Andere</label>
97 <pointsymbol>hard:circle</pointsymbol>
98 <pointsize>2</pointsize>
99 <pointsizeunits>pixels</pointsizeunits>
100 <rotationclassificationfieldname/>
101 <scaleclassificationfieldname/>
102 <symbolfieldname/>
103 <outlinecolor red="0" blue="0" green="0"/>
104 <outlinestyle>DashDotDotLine</outlinestyle>
105 <outlinewidth>0.26</outlinewidth>
106 <fillcolor red="59" blue="81" green="179"/>
107 <fillpattern>SolidPattern</fillpattern>
108 <texturepath null="1"/>
109 </symbol>
110 <uniquevalue>
111 <classificationfield>CLASS</classificationfield>
112 <xsl:apply-templates/>
113 </uniquevalue>
114 <edittypes>
115 <edittype type="0" name="CLASS"/>
116 <edittype type="0" name="DATE"/>
117 <edittype type="0" name="LAYER"/>
118 <edittype type="0" name="PARAMETER"/>
119 </edittypes>
120 <editform/>
121 <editforminit/>
122 <displayfield>PARAMETER</displayfield>
123 <label>0</label>
124 <attributeactions/>
125 <labelattributes>
126 <label fieldname="" text="Beschriftung"/>
127 <family fieldname="" name="Sans Serif"/>
128 <size fieldname="" units="pt" value="12"/>
129 <bold fieldname="" on="0"/>
130 <italic fieldname="" on="0"/>
131 <underline fieldname="" on="0"/>
132 <color fieldname="" red="0" blue="0" green="0"/>
133 <x fieldname=""/>
134 <y fieldname=""/>
135 <offset x="0" y="0" units="pt" yfieldname="" xfieldname=""/>
136 <angle fieldname="" value="0" auto="0"/>
137 <alignment fieldname="" value="center"/>
138 <buffercolor fieldname="" red="255" blue="255" green="255"/>
139 <buffersize fieldname="" units="pt" value="1"/>
140 <bufferenabled fieldname="" on=""/>
141 <multilineenabled fieldname="" on=""/>
142 </labelattributes>
143 </qgis>
144 </xsl:template>
145 <xsl:template match="text()"/>
146 </xsl:stylesheet>

http://dive4elements.wald.intevation.org