[mapserver-users] XML interface for query templates

Cameron Shorter cameron at socialchange.net.au
Sun Apr 22 16:45:08 PDT 2001


Hi,
We are playing around with a perl wrapper for mapserv which will provide
a GML interface to mapserv.

However, we have run into a problem with queries.  Query responses need
to be returned in XML format.  Some the the .dbf files we have contain
">" chars which needs to be converted to ">" if it used in an XML
response.  Currently, this option does not seem to be available in
mapserv.

So, what I'd like to add to the query object is an option like:
* xml_conversion [true|false] which defaults to false

When xml_conversion=true, data from the .dbf columns will be converted
to be xml compliant.


If this is OK by mapserv architects and our clients, then we will go
ahead and implement it.

--------
The logic required would be something like the following (example in
perl)

        # Make the strings XML compliant:
        for (@_) {
                s/\&/&/g;
                s/\</</g;
                s/\>/>/g;

                # strip quotes if they are at wrapped around a term but
don't
                # remove them if they are in the middle of a term.
                # Ie, "Towns" = Towns
                #      Town's = Town's
                s/^\'(.*)\'$/$1/;
                s/^\"(.*)\"$/$1/;
                s/\'/'/g;
                s/\"/"/g;
        }

--------
The extra parameter would need to be inserted in maplexer.l

--------

My guess is that the xml conversion would need to be inserted in
mapserv.c somewhere near line 1277:

	for(i=0;i<Query->numitems;i++) {	 
	  sprintf(substr, "[%s]", Query->items[i]);
	  if(strstr(outstr, substr) != NULL) { /* do substitution */
	    outstr = gsub(outstr, substr, Query->data[i]);
	  }
	} /* next item */

...


-- 
Cameron Shorter          Web Mapping Manager
Social Change Online
248 Johnson St           Tel: +61 (0) 2 9692 5115
Annandale NSW 2038       Fax: +61 (0) 2 9692 5192
Sydney, Australia        http://webmap.socialchange.net.au



More information about the MapServer-users mailing list