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