From Sumo
Revision as of 19:20, 11 September 2018 by Namdre (talk | contribs) (disabling schema validation)
Jump to navigation Jump to search

Validation of XML inputs

All SUMO applications support XML validation for their inputs. To enable this, the following options can be used:

Option Description
--xml-validation <STRING>
Set schema validation scheme of XML inputs ("never", "auto" or "always"); default: auto
--xml-validation.net <STRING> Set schema validation scheme of SUMO network inputs ("never", "auto" or "always"); default: never

Validation is performed by activating XML schema processing in the XML parser. This catches many common input errors such as spelling mistakes and attributes which should have been placed within another element.

Another prerequisite for validation is a schema deceleration within the root element of the input file such as

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">

When setting the validation options to always it is an error to omit this declaration.

Schema validation may slowdown XML parsing considerably and is therefore disabled for the network input by default (because networks should not be edited by hand and therefore be valid anyway).

If you have large auto-generated inputs you may consider disabling schema validation altogether. See also this FAQ


Adding a schema declaration

Files that are written by one of the SUMO applications automatically receive the appropriate schema declaration. When writing an input file from scratch the schema declaration must be added manually to the root element as follows:

<ROOT_ELEMENT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

where ROOT_ELEMENT and SCHEMA_FILE should be set according to the following table:

--route-files}, --trip-files, , --flow-files routes routes_file.xsd
--additional-files add additional_file.xsd
--node-files nodes nodes_file.xsd
--edge-files edges edges_file.xsd
--connection-files connections connections_file.xsd
--tllogic-files tlLogics tllogic_file.xsd
--type-files types types_file.xsd
--weight-files meandata meandata_file.xsd
The value of ROOT_ELEMENT is a matter of convention and may take an arbitrary value.

Schema Files

The schema files can be found in the <SUMO_HOME>/data/xsd directory of your SUMO installation. If the environment variable SUMO_HOME is set, these files will be used when validation inputs.

Otherwise, the files are loaded from http://sumo.dlr.de/xsd/SCHEMA_FILE which may slow down the application (or fail if there is no internet connection).

SUMO File Types

A complete listing of file extensions used by SUMO Applications is given at File_Extensions.

Disabling Schema Validation

To disable schema validation any of the following actions is sufficient