[mapserver-commits] r9788 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Feb 10 13:42:05 EST 2010


Author: assefa
Date: 2010-02-10 13:42:03 -0500 (Wed, 10 Feb 2010)
New Revision: 9788

Modified:
   trunk/mapserver/mapowscommon.c
   trunk/mapserver/mapowscommon.h
   trunk/mapserver/mapwfs11.c
Log:
WFS 1.1.0: use encoding when outputting some parameters #3297

Modified: trunk/mapserver/mapowscommon.c
===================================================================
--- trunk/mapserver/mapowscommon.c	2010-02-10 16:43:03 UTC (rev 9787)
+++ trunk/mapserver/mapowscommon.c	2010-02-10 18:42:03 UTC (rev 9788)
@@ -637,4 +637,20 @@
     return MS_FAILURE;
 }
 
+xmlNodePtr msOWSCommonxmlNewChildEncoded( xmlNodePtr psParent, xmlNsPtr psNs, const char* name, 
+					  const char *content, const char *encoding)
+{
+    char *encoded = NULL;
+    xmlNodePtr psNode;
+
+    if (encoding && content)
+    {
+	encoded = msGetEncodedString(content, encoding);
+	psNode =  xmlNewChild(psParent, psNs, BAD_CAST name, BAD_CAST encoded);
+	msFree(encoded);
+	return psNode;
+    }
+    else
+      return xmlNewChild(psParent, psNs, BAD_CAST name, BAD_CAST content);
+}
 #endif /* defined(USE_LIBXML2) */

Modified: trunk/mapserver/mapowscommon.h
===================================================================
--- trunk/mapserver/mapowscommon.h	2010-02-10 16:43:03 UTC (rev 9787)
+++ trunk/mapserver/mapowscommon.h	2010-02-10 18:42:03 UTC (rev 9788)
@@ -94,6 +94,8 @@
 
 int _validateNamespace(xmlNsPtr psNsOws);
 
+xmlNodePtr msOWSCommonxmlNewChildEncoded( xmlNodePtr psParent, xmlNsPtr psNs, const char* name,
+                                          const char *content, const char *encoding);
 #endif /* defined(USE_LIBXML2) */
 
 #endif /* MAPOWSCOMMON_H */

Modified: trunk/mapserver/mapwfs11.c
===================================================================
--- trunk/mapserver/mapwfs11.c	2010-02-10 16:43:03 UTC (rev 9787)
+++ trunk/mapserver/mapwfs11.c	2010-02-10 18:42:03 UTC (rev 9788)
@@ -103,11 +103,21 @@
    
     xmlNodePtr psRootNode, psNode;
     const char *value    = NULL;
+    const char *encoding = NULL;
+    char *encoded=NULL;
+      
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+    if (!encoding)
+      encoding = "ISO-8859-1";
+
     psRootNode = xmlNewNode(NULL, BAD_CAST "FeatureType");
 
-    psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "Name", BAD_CAST lp->name);
 
+    /*if there is an encoding using it on some of the items*/
+    msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Name", lp->name, encoding);
+
+
     if (lp->name && strlen(lp->name) > 0 &&
         (msIsXMLTagValid(lp->name) == MS_FALSE || isdigit(lp->name[0])))
       xmlAddSibling(psNode,
@@ -115,24 +125,32 @@
                                   "invalid characters or may start with a number. This could lead to potential problems"));
    
     value = msOWSLookupMetadata(&(lp->metadata), "FO", "title");
-    if (value)
-      psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "Title", BAD_CAST value);
-    else
-      psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "Title", BAD_CAST lp->name);
+    if (!value)
+      value =(const char*)lp->name;
 
+    psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Title", value, encoding);
 
+ 
     value = msOWSLookupMetadata(&(lp->metadata), "FO", "abstract");
     if (value)
-      psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "Abstract", BAD_CAST value);
+      psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Abstract", value, encoding);
 
 
+
     value = msOWSLookupMetadata(&(lp->metadata), "FO", "keywordlist");
 
     if (value)
+    {
+	if (encoding)
+	  encoded = msGetEncodedString(value, encoding);
+        else
+          encoded = msGetEncodedString(value, "ISO-8859-1");
+
         msLibXml2GenerateList(
             xmlNewChild(psRootNode, psNsOws, BAD_CAST "Keywords", NULL),
-            NULL, "Keyword", value, ',' );
-
+            NULL, "Keyword", encoded, ',' );
+	msFree(encoded);
+    }
     /*srs only supposrt DefaultSRS with the same logic as for wfs1.0
       TODO support OtherSRS*/
     value = msOWSGetEPSGProj(&(map->projection),&(map->web.metadata),"FO",MS_TRUE);



More information about the mapserver-commits mailing list