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