[mapserver-commits] r9973 - in trunk/mapserver: . xmlmapfile xmlmapfile/tests

svn at osgeo.org svn at osgeo.org
Mon Mar 22 11:58:07 EDT 2010


Author: aboudreault
Date: 2010-03-22 11:58:07 -0400 (Mon, 22 Mar 2010)
New Revision: 9973

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/xmlmapfile/mapfile.xsd
   trunk/mapserver/xmlmapfile/mapfile.xsl
   trunk/mapserver/xmlmapfile/tests/layerset.xml
Log:
Fixed XML transformation issues with expressions and symbols (#3397)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2010-03-22 14:32:22 UTC (rev 9972)
+++ trunk/mapserver/HISTORY.TXT	2010-03-22 15:58:07 UTC (rev 9973)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Fixed XML transformation issues with expressions and symbols (#3397)
+
 - Check error returns from mapstring functions (#2988)
 
 - Add support for multiliple srs in  WFS 1.1.0 (#3227)

Modified: trunk/mapserver/xmlmapfile/mapfile.xsd
===================================================================
--- trunk/mapserver/xmlmapfile/mapfile.xsd	2010-03-22 14:32:22 UTC (rev 9972)
+++ trunk/mapserver/xmlmapfile/mapfile.xsd	2010-03-22 15:58:07 UTC (rev 9973)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ms="http://www.mapserver.org/mapserver" targetNamespace="http://www.mapserver.org/mapserver" elementFormDefault="qualified" attributeFormDefault="unqualified" version="5.6.0">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ms="http://www.mapserver.org/mapserver" targetNamespace="http://www.mapserver.org/mapserver" elementFormDefault="qualified" attributeFormDefault="unqualified" version="5.6.3">
 	<!-- Definition of types -->
 	<xs:simpleType name="rgbColorValueType">
 		<xs:restriction base="xs:integer">
@@ -123,6 +123,35 @@
 			<xs:enumeration value="RIGHT"/>
 		</xs:restriction>
 	</xs:simpleType>
+	<xs:complexType name="expressionType">
+          <xs:simpleContent>
+	    <xs:extension base="xs:string">
+	      <xs:attribute name="type" default="CONSTANT">
+                <xs:simpleType>
+	          <xs:restriction base="xs:string">
+	            <xs:enumeration value="CONSTANT"/>
+	            <xs:enumeration value="REGEX"/>
+                    <xs:enumeration value="MSEXPR"/>
+		  </xs:restriction>
+                </xs:simpleType>
+              </xs:attribute>
+	    </xs:extension>
+	  </xs:simpleContent>
+	</xs:complexType>
+	<xs:complexType name="symbolType">
+          <xs:simpleContent>
+	    <xs:extension base="xs:string">
+	      <xs:attribute name="type" default="ID">
+                <xs:simpleType>
+	          <xs:restriction base="xs:string">
+	            <xs:enumeration value="ID"/>
+                    <xs:enumeration value="NAME"/>
+		  </xs:restriction>
+                </xs:simpleType>
+              </xs:attribute>
+	    </xs:extension>
+	  </xs:simpleContent>
+	</xs:complexType>
 	<!-- Definition of Mapfile elements -->
 	<!-- QUERYMAP Definition -->
 	<xs:complexType name="QueryMap">
@@ -371,11 +400,7 @@
 					<xs:union memberTypes="xs:positiveInteger ms:attributeType"/>
 				</xs:simpleType>
 			</xs:element>
-			<xs:element name="symbol" default="1" minOccurs="0">
-				<xs:simpleType>
-					<xs:union memberTypes="xs:positiveInteger xs:string"/>
-				</xs:simpleType>
-			</xs:element>
+			<xs:element name="symbol" type="ms:symbolType" default="1" minOccurs="0"/>
 			<xs:element name="width" default="1" minOccurs="0">
 				<xs:simpleType>
 					<xs:union memberTypes="xs:positiveInteger ms:attributeType"/>
@@ -389,7 +414,7 @@
 			<xs:element name="backgroundColor" type="ms:rgbColorType" minOccurs="0"/>
 			<xs:element name="color" type="ms:rgbColorType" minOccurs="0"/>
 			<xs:element name="debug" type="ms:stateEnum" minOccurs="0"/>
-			<xs:element name="expression" type="xs:string" minOccurs="0"/>
+			<xs:element name="expression" type="ms:expressionType" minOccurs="0"/>
 			<xs:element name="group" type="xs:string" minOccurs="0"/>
 			<xs:element name="keyImage" type="xs:string" minOccurs="0"/>
 			<xs:element name="Label" type="ms:Label" minOccurs="0"/>
@@ -403,11 +428,7 @@
 			</xs:choice>
 			<xs:element name="size" type="xs:positiveInteger" default="1" minOccurs="0"/>
 			<xs:element name="Style" type="ms:Style" minOccurs="0" maxOccurs="unbounded"/>
-			<xs:element name="symbol" default="1" minOccurs="0">
-				<xs:simpleType>
-					<xs:union memberTypes="xs:positiveInteger xs:string"/>
-				</xs:simpleType>
-			</xs:element>
+			<xs:element name="symbol" type="ms:symbolType" default="1" minOccurs="0"/>
 			<xs:element name="template" type="xs:string" minOccurs="0"/>
 			<xs:element name="text" type="xs:string" minOccurs="0"/>
 		</xs:sequence>
@@ -580,7 +601,7 @@
 				</xs:simpleType>
 			</xs:element>
 			<xs:element name="Feature" type="ms:Feature" minOccurs="0" maxOccurs="unbounded"/>
-			<xs:element name="filter" type="xs:string" minOccurs="0"/>
+			<xs:element name="filter" type="ms:expressionType" minOccurs="0"/>
 			<xs:element name="filterItem" type="xs:string" minOccurs="0"/>
 			<xs:element name="footer" type="xs:string" minOccurs="0"/>
 			<xs:element name="Grid" type="ms:Grid" minOccurs="0"/>

Modified: trunk/mapserver/xmlmapfile/mapfile.xsl
===================================================================
--- trunk/mapserver/xmlmapfile/mapfile.xsl	2010-03-22 14:32:22 UTC (rev 9972)
+++ trunk/mapserver/xmlmapfile/mapfile.xsl	2010-03-22 15:58:07 UTC (rev 9973)
@@ -79,6 +79,69 @@
   </xsl:choose>
 </xsl:template>
 
+<xsl:template name="printExpression">
+  <xsl:param name="indent"/>
+  <xsl:param name="node" select="/"/>
+
+  <xsl:if test="$node">
+    <xsl:variable name="quote">
+      <xsl:choose>
+        <xsl:when test="dyn:evaluate($node)/@type = 'CONSTANT'">
+          <xsl:value-of select='1'/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select='0'/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:variable name="textValue">
+      <xsl:call-template name="getString">
+        <xsl:with-param name="nodeName" select="$node"/>
+        <xsl:with-param name="quote" select="$quote"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:call-template name="print">
+      <xsl:with-param name="indent" select="$indent"/>
+      <xsl:with-param name="quote" select="$quote"/>
+      <xsl:with-param name="text" select="$textValue"/>
+    </xsl:call-template>
+
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="printSymbol">
+  <xsl:param name="indent"/>
+  <xsl:param name="node" select="/"/>
+
+  <xsl:if test="$node">
+    <xsl:variable name="quote">
+      <xsl:choose>
+        <xsl:when test="dyn:evaluate($node)/@type = 'NAME'">
+          <xsl:value-of select='1'/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select='0'/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:variable name="textValue">
+      <xsl:call-template name="getString">
+        <xsl:with-param name="nodeName" select="$node"/>
+        <xsl:with-param name="quote" select="$quote"/>
+      </xsl:call-template>
+    </xsl:variable>
+    
+    <xsl:call-template name="print">
+      <xsl:with-param name="quote" select="$quote"/>
+      <xsl:with-param name="text" select="$textValue"/>
+      <xsl:with-param name="indent" select="$indent"/>
+    </xsl:call-template>
+
+  </xsl:if>
+</xsl:template>
+
   <xsl:template match="/">
     <xsl:apply-templates select="ms:SymbolSet"/>
     <xsl:apply-templates select="ms:LayerSet"/>
@@ -746,7 +809,7 @@
       <xsl:with-param name="indent" select="$indent"/>
       <xsl:with-param name="node" select="'ms:size'"/>
     </xsl:call-template>
-    <xsl:call-template name="print">
+    <xsl:call-template name="printSymbol">
       <xsl:with-param name="indent" select="$indent"/>
       <xsl:with-param name="node" select="'ms:symbol'"/>
     </xsl:call-template>
@@ -788,10 +851,9 @@
       <xsl:with-param name="indent" select="$indent"/>
       <xsl:with-param name="node" select="'ms:debug'"/>
     </xsl:call-template>
-    <xsl:call-template name="print">
+    <xsl:call-template name="printExpression">
       <xsl:with-param name="indent" select="$indent"/>
       <xsl:with-param name="node" select="'ms:expression'"/>
-      <xsl:with-param name="quote" select="1"/>
     </xsl:call-template>
     <xsl:call-template name="print">
       <xsl:with-param name="indent" select="$indent"/>
@@ -836,7 +898,7 @@
     <xsl:apply-templates select="ms:Style">
       <xsl:with-param name="indent" select="$indent + 1"/>
     </xsl:apply-templates>
-    <xsl:call-template name="print">
+    <xsl:call-template name="printSymbol">
       <xsl:with-param name="indent" select="$indent"/>
       <xsl:with-param name="node" select="'ms:symbol'"/>
     </xsl:call-template>
@@ -1129,10 +1191,9 @@
     <xsl:apply-templates select="ms:Feature">
       <xsl:with-param name="indent" select="$indent + 1"/>
     </xsl:apply-templates>
-    <xsl:call-template name="print">
+    <xsl:call-template name="printExpression">
       <xsl:with-param name="indent" select="$indent"/>
       <xsl:with-param name="node" select="'ms:filter'"/>
-      <xsl:with-param name="quote" select="1"/>
     </xsl:call-template>
     <xsl:call-template name="print">
       <xsl:with-param name="indent" select="$indent"/>
@@ -1288,7 +1349,7 @@
   </xsl:template>
   
   <xsl:template match="ms:SymbolSet">
-    <xsl:param name="indent" select="1"/>
+    <xsl:param name="indent" select="0"/>
     <xsl:call-template name="print">
       <xsl:with-param name="text" select="'SYMBOLSET&#xa;'"/>
     </xsl:call-template>
@@ -1301,14 +1362,14 @@
   </xsl:template>
 
   <xsl:template match="ms:LayerSet">
-    <xsl:param name="indent" select="1"/>
+    <xsl:param name="indent" select="0"/>
     <xsl:apply-templates select="ms:Layer">
       <xsl:with-param name="indent" select="$indent + 1"/>
     </xsl:apply-templates>
   </xsl:template>
 
   <xsl:template match="ms:Map">
-    <xsl:param name="indent" select="1"/>
+    <xsl:param name="indent" select="0"/>
     <xsl:call-template name="print">
       <xsl:with-param name="text" select="'MAP&#xa;'"/>
     </xsl:call-template>

Modified: trunk/mapserver/xmlmapfile/tests/layerset.xml
===================================================================
--- trunk/mapserver/xmlmapfile/tests/layerset.xml	2010-03-22 14:32:22 UTC (rev 9972)
+++ trunk/mapserver/xmlmapfile/tests/layerset.xml	2010-03-22 15:58:07 UTC (rev 9973)
@@ -5,7 +5,7 @@
       <backgroundColor red="244" green="43" blue="22"/>
       <color red="244" green="43" blue="22"/>
       <debug>ON</debug>
-      <expression>(length('[NAME_E]') &lt; 8)</expression>
+      <expression type="MSEXPR">(length('[NAME_E]') &lt; 8)</expression>
       <group>group1</group>
       <keyImage>/home/myusername/layer1.png</keyImage>
       <Label type="TRUETYPE">
@@ -56,10 +56,10 @@
         <opacity>1253</opacity>
         <outlineColorAttribute>[myOulineColorAttribute]</outlineColorAttribute>
         <size>[mySize]</size>
-        <symbol>star.gif</symbol>
+        <symbol type="NAME">star.gif</symbol>
         <width>[myWidth]</width>
       </Style>
-      <symbol>261</symbol>
+      <symbol type="ID">261</symbol>
       <template>http://mapgears.com/templates/myTemplates1.html</template>
       <text>myText1</text>
     </Class>
@@ -74,7 +74,7 @@
     <Feature>
       <wkt>POINT(2000 2500)</wkt>
     </Feature>
-    <filter>type=’road’ and size &lt; 2</filter>
+    <filter type="MSEXPR">(type=’road’ and size &lt; 2)</filter>
     <filterItem>pop</filterItem>
     <footer>http://mapgears.com/templates/myfooter1.html</footer>
     <Grid>



More information about the mapserver-commits mailing list