[mapserver-dev] XML validation script in msautotest

Even Rouault even.rouault at mines-paris.org
Sat Oct 26 12:31:02 PDT 2013


I've added in master a msautotest/pymod/xmlvalidate.py script that can be used 
to validate XML documents. It is tuned for XML documents using OGC schemas, 
but can potentially work in other contexts.

To use it, as a preliminary step, you need to first download the OGC schemas 
and rewrite the URLs so that everything is local to have very fast validation 
( I did try the XML_CATALOG_FILES mechanism to avoid rewriting URLs but there 
were some libxml2 warnings that confused lxml ):

cd msautotest/wxs
python ../pymod/xmlvalidate.py -download_ogc_schemas

Then you can do for example :

$ python ../pymod/xmlvalidate.py expected/sos_cap.xml

(no output so validates)

Or more interesting :

$ python ../pymod/xmlvalidate.py -schema expected/wfs_describe.xml 
Element '{http://mapserver.gis.umn.edu/mapserver}province', attribute 'fid': 
'province.Nova Scotia' is not a valid value of the atomic type 'xs:ID'., line 

Well in that case, it happens that our mapfile configuration is not correct as 
we use an attribute that can generate invalid gml:id for features.

(The script has some tuning to discard the mime headers in .xml files, to make 
it easier to use)

For now, I've added its use when XML POST requests are done in tests. This 
only prints a warning message when XML validation fails

I've fixed one instance of invalid XML POST in wfs_filter.map  ( 
) but I can see many warnings in wcs_post.map. The main reason is the absence 
of " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
http://schemas.opengis.net/wcs/2.0/wcsAll.xsd"", but even when adding it, 
there are errors in some GetCoverage requests.

We could also imagine adding special syntax in .map to ask for the output of a 
request to be validated.

# XML_VALIDATE the_xml.xml [ the_schema.xml ]

Have fun !


Geospatial professional services

More information about the mapserver-dev mailing list