RE: [mapserver-users] Mapfile verification tool
Other than using shp2img or one of the other command-line executables I'm afraid there isn't a validator. Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Alberto Najera Sent: Monday, May 14, 2012 8:35 PM To: mapserver-users@lists.osgeo.org Subject: [mapserver-users] Mapfile verification tool Hello all, Is there a tool available to check the mapfile syntax? I am working with a file that is getting quite large and it is easy to, for example, miss or add an END. Thanks Alberto Najera ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mapfile verification tool
On 05/15/2012 03:56 PM, Lime, Steve D (DNR) wrote: Other than using shp2img or one of the other command-line executables I'm afraid there isn't a validator. What about writing some trivial mapscript script which will loop over all layers in mapfile. If some syntax error would be found some exception will be raised ? -- Ivan Mincik ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mapfile verification tool
On 5/15/2012 11:02 AM, Ivan Mincik wrote: On 05/15/2012 03:56 PM, Lime, Steve D (DNR) wrote: Other than using shp2img or one of the other command-line executables I'm afraid there isn't a validator. What about writing some trivial mapscript script which will loop over all layers in mapfile. If some syntax error would be found some exception will be raised ? Ivan, I don't think this will work because the mapfile is read all at once and parsed into an internal data structure. You can't access it in mapscript until the parser has read it and the parser will error out on any errors. I think you would need to modify the parser and add some kind of error recovery to continue parsing the rest of the file to report additional errors. Currently there is no attempt to recover from an error because we assume that the mapfile should be valid in the production environment. For development/debugging purposes, you would have to add the error recovery code. -Steve W ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mapfile verification tool
I don't think this will work because the mapfile is read all at once and parsed into an internal data structure. You can't access it in mapscript until the parser has read it and the parser will error out on any errors. Understand, but i mean only valid/invalid output from test script. If some error will raised - mapfile is invalid, with no other information where otherwise mapfile is OK. -- Ivan Mincik ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mapfile verification tool
I mean something like this: import sys import mapscript try: m = mapscript.mapObj(sys.argv[1]) print 'VALID (%s layers found)' % m.numlayers except: print 'INVALID' I did some tests and it seems working. Even it outputs detailed parsing error message (for example: loadProjection(): Unknown identifier. Parsing error near (METADATA):(line 100)) ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Mapfile verification tool
Shp2img already provides this capability and is more portable than MapScript. I think ideally we'd develop a validator that spits out all errors but that's probably not possible either since many common error states (like a missing END or quote) will trigger a whole bunch of false positives. Best to take it an error at a time for most cases. This might be useful more for between version migration where the mapfile is structurally sound but keywords have changed. We could write a dumber version of shp2img that only tries to load the mapfile and report an error but I'm not sure it's worth the effort. Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Ivan Mincik Sent: Tuesday, May 15, 2012 10:24 AM To: mapserver-users Subject: Re: [mapserver-users] Mapfile verification tool I don't think this will work because the mapfile is read all at once and parsed into an internal data structure. You can't access it in mapscript until the parser has read it and the parser will error out on any errors. Understand, but i mean only valid/invalid output from test script. If some error will raised - mapfile is invalid, with no other information where otherwise mapfile is OK. -- Ivan Mincik ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Mapfile verification tool
All, I've approached this topic over the years by having a nice Syntax editor available for MapFiles. Both VI and UltraEdit have proven to have good syntax templates for highlighting of edited MAPFILEs. I know this is exactly what was being asked about. But upon further thought, I wonder if a VI script couldn't be put together to do some of this checking, at least in pairing of quotes and END statements. Just a thought. bobb Lime, Steve D (DNR) steve.l...@state.mn.us wrote: Shp2img already provides this capability and is more portable than MapScript. I think ideally we'd develop a validator that spits out all errors but that's probably not possible either since many common error states (like a missing END or quote) will trigger a whole bunch of false positives. Best to take it an error at a time for most cases. This might be useful more for between version migration where the mapfile is structurally sound but keywords have changed. We could write a dumber version of shp2img that only tries to load the mapfile and report an error but I'm not sure it's worth the effort. Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Ivan Mincik Sent: Tuesday, May 15, 2012 10:24 AM To: mapserver-users Subject: Re: [mapserver-users] Mapfile verification tool I don't think this will work because the mapfile is read all at once and parsed into an internal data structure. You can't access it in mapscript until the parser has read it and the parser will error out on any errors. Understand, but i mean only valid/invalid output from test script. If some error will raised - mapfile is invalid, with no other information where otherwise mapfile is OK. -- Ivan Mincik ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Mapfile verification tool
Oops, sorry about the typo below, I meant to say I know this isn't exactly . . . bobb Bob Basques bob.basq...@ci.stpaul.mn.us wrote: All, I've approached this topic over the years by having a nice Syntax editor available for MapFiles. Both VI and UltraEdit have proven to have good syntax templates for highlighting of edited MAPFILEs. I know this is exactly what was being asked about. But upon further thought, I wonder if a VI script couldn't be put together to do some of this checking, at least in pairing of quotes and END statements. Just a thought. bobb Lime, Steve D (DNR) steve.l...@state.mn.us wrote: Shp2img already provides this capability and is more portable than MapScript. I think ideally we'd develop a validator that spits out all errors but that's probably not possible either since many common error states (like a missing END or quote) will trigger a whole bunch of false positives. Best to take it an error at a time for most cases. This might be useful more for between version migration where the mapfile is structurally sound but keywords have changed. We could write a dumber version of shp2img that only tries to load the mapfile and report an error but I'm not sure it's worth the effort. Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Ivan Mincik Sent: Tuesday, May 15, 2012 10:24 AM To: mapserver-users Subject: Re: [mapserver-users] Mapfile verification tool I don't think this will work because the mapfile is read all at once and parsed into an internal data structure. You can't access it in mapscript until the parser has read it and the parser will error out on any errors. Understand, but i mean only valid/invalid output from test script. If some error will raised - mapfile is invalid, with no other information where otherwise mapfile is OK. -- Ivan Mincik ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mapfile verification tool
What's the state of the XML mapfile? Could one create their mapfile in an XML editor to generate a syntactically valid mapfile (through xslt) then use shp2img to verify data connections? On 5/15/2012 11:57 AM, Lime, Steve D (DNR) wrote: Shp2img already provides this capability and is more portable than MapScript. I think ideally we'd develop a validator that spits out all errors but that's probably not possible either since many common error states (like a missing END or quote) will trigger a whole bunch of false positives. Best to take it an error at a time for most cases. This might be useful more for between version migration where the mapfile is structurally sound but keywords have changed. We could write a dumber version of shp2img that only tries to load the mapfile and report an error but I'm not sure it's worth the effort. Steve -Original Message- From: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Ivan Mincik Sent: Tuesday, May 15, 2012 10:24 AM To: mapserver-users Subject: Re: [mapserver-users] Mapfile verification tool I don't think this will work because the mapfile is read all at once and parsed into an internal data structure. You can't access it in mapscript until the parser has read it and the parser will error out on any errors. Understand, but i mean only valid/invalid output from test script. If some error will raised - mapfile is invalid, with no other information where otherwise mapfile is OK. -- Ivan Mincik ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.455 / Virus Database: 271.1.1/4999 - Release Date: 05/14/12 18:05:00 ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
RE: [mapserver-users] Mapfile verification tool
Well, we spend a few hours debugging a 900 plus lines mapfile. We missed a few ends, had a few extra of them plus some other errors like typos in the source file calls. So a tool like this would be extremely useful. I use UltraEdit version 14.00a and have was not aware of such a template. How can it be activated? Alberto Najera De: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-boun...@lists.osgeo.org] En nombre de Bob Basques Enviado el: martes, 15 de mayo de 2012 11:14 a.m. Para: ivan.min...@gmail.com; mapserver-users; Steve D (DNR) Lime Asunto: RE: [mapserver-users] Mapfile verification tool All, I've approached this topic over the years by having a nice Syntax editor available for MapFiles. Both VI and UltraEdit have proven to have good syntax templates for highlighting of edited MAPFILEs. I know this is exactly what was being asked about. But upon further thought, I wonder if a VI script couldn't be put together to do some of this checking, at least in pairing of quotes and END statements. Just a thought. bobb ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users