[mapserver-users] XML interface for query templates

Stephen Lime steve.lime at dnr.state.mn.us
Mon Apr 23 11:40:30 PDT 2001


Hi Cameron: We're also working on XML output, initially as part of WMS compliance
but then in a more general sense. I do see the need to allow XML (and even just HTML)
output as part of general template usage. I assume that's where you're running into
trouble. If you're accessing the features directly in perl and producing the XML from
within the scripts (eg. not using templates) then it's easy enough to do the substitution
in perl. Here's what I propose:

3.5 already allows you to change DBF item filtering in templates so you can request
an item called NAME using [NAME] or [NAME_esc]. The first gets you the straight
string, the second gets you the string escaped for inclusion in a GET request. It would
be easy to add a third option [NAME_xml] or similar that would XML escaped equivilalent.

If you could come up with the function to do the XML escaping, it's got to already
exist someplace, then I could add this to 3.5 (which is really pretty stable) in a few minutes.

Let me know what you think.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Cameron Shorter <cameron at socialchange.net.au> 04/22/01 06:45PM >>>
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