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