Mapscript - tricky save map problem when DATA containes quotes

Daniel Caldeweyher calde at GMX.NET
Fri Apr 29 01:39:18 EDT 2005


Hi,

I have encountered a bit of a tricky situation. My mapping application
allows users to dynamically add layers using a wizard (similar to MS-ACCESS
Report Wizard, where the user can select fields from different tables). The
application generates SQL from this selection, more precise, the truncated
SQL part which forms the DATA element of a layer. To be on the safe side
with table and column names (I use PostGIS) I put all names in quotes.
However when I then dynamically save the mapobj to a mapfile, mapscript
places quotes around the DATA statement, which when trying to load that file
again, will cause problems as the parse thinks the the first quote is the
end of the DATA element, which it obviously isn't.

I noticed that with EXPRESSION's when putting the expression inside
parantheses () it will not enclose the expression with quotes, however
trying to do so with DATA doesn't work.

Since I keep the meta-information of my layer wizard, I can just simply set
DATA to an empty string before saving the map, and use that meta-information
(stored in the file as METADATA) I can re-generate my DATA string when
loading the file. However I don't like this solution and was wondering if
there is a better solution for cases when the DATA string itself contains
quotes (as well as single quotes).

Thanks,

Daniel



More information about the mapserver-users mailing list