wmo-im / iwxxm

XML schema and Schematron for aviation weather data exchange
https://old.wmo.int/wiswiki/tiki-index.php%3Fpage=TT-AvXML
50 stars 22 forks source link

Namespace of the imported AIXM WX Profile #199

Closed blchoy closed 4 years ago

blchoy commented 4 years ago

Scott Wilson of EUROCONTROL reported an issue involving the validity of an XSD importing multiple XMs including IWXXM (see this page for details).

The following is a sample XSD file to showcase the issue:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
        xmlns:iwxxm="http://icao.int/iwxxm/3.0" 
        xmlns:aixm="http://www.aixm.aero/schema/5.1.1" 
        xmlns:test="http://domain/test" 
        targetNamespace="http://domain/test" elementFormDefault="qualified">

    <import namespace="http://icao.int/iwxxm/3.0" schemaLocation="http://schemas.wmo.int/iwxxm/3.0/iwxxm.xsd"/>
    <import namespace="http://www.aixm.aero/schema/5.1.1" schemaLocation="http://www.aixm.aero/schema/5.1.1/AIXM_Features.xsd"/>

    <complexType name="AIXMFeatureType">
        <sequence>
            <!-- This AIXM feature is not in the AIXM WX Profile -->
            <element name="AIXMFeature" type="aixm:SurveillanceGroundStationType"/>
        </sequence>
    </complexType>

    <complexType name="IWXXMFeatureType">
        <sequence>
            <element name="IWXXMFeature" type="iwxxm:TAFType"/>
        </sequence>
    </complexType>

</schema>

Validating this XSD with OxygenXML Editor and option "honour all schema locations" disabled will result an error indicating that "aixm:SurveillanceGroundStationType" has not been defined.

If AIXM is imported before IWXXM, however, there will be no validation error.

Of course if "honour all schema locations" is enabled it will return errors indicating that some features have been defined twice, irrespective of the order of the imports.

The reason is that Xerces-based XML Schema validator acknowledges only the first import for the same namespace by default. Of course the root cause is the use of the same namespace for both AIXM and AIXM WX Profile, the latter of which is imported in IWXXM's common.xsd:

<import namespace="http://www.aixm.aero/schema/5.1.1" schemaLocation="http://www.aixm.aero/schema/5.1.1_profiles/AIXM_WX/5.1.1b/AIXM_Features.xsd"></import>

As mentioned by Scott, we can resolve this by either (i) importing the full AIXM in common.xsd or (ii) changing the namespace referencing the AIXM WX Profile.

Option (i) is probably the simplest solution as it involves a patch to common.xsd and WMO No.306. The only drawback is the need to import all AIXM features which may be a burden to the parsers/validators. This also defeats the original intention of having the AIXM WX Profile.

Option (ii) involves changes to common.xsd, WMO No.306, examples and more. We will also have to remind users to define namespace for the AIXM WX Profile in their IWXXM instances which is a huge amount of work.

Personally I don't think we need an urgent fix right now as this deficiency only affects SWIM services under development and could be get around with the choice of parser/validator and/or configuration options.

Views please.

riannella commented 4 years ago

The IWXXM/AIXM Profiles uses the same XML Namespace identifier as the AIXM XML Namespace. This creates errors when trying to validate (full) AIXM and IWXXM in the same system environment. An XML Namespace should be unique to a specific XSD - as it is its normative identifier.

I think there is an easy “fix” for this. And this is to use the XML Schema feature. This simply allows you to “override” any (and all) definitions of an XML schema (whilst preserving the XML Namespace).

I tried to test this out (see attached xsd) but I could not do a final validation as I get consistent (and many) errors from the recursive import of the GML schemas. (Has any else reported that?)

If this works, then all you need to do is this xsd in common.xsd.

AIXM-Features-IWXXM-Profile.zip

riannella commented 4 years ago

..but I think the better strategy is to adopt the full AIXM Schema!

blchoy commented 4 years ago

IWXXM schemas imports the full AIXM Schema starting from Version 3.0-dev.