0

I have a kml xml instance that validates fine with all the microsoft xml engines, but fails validation with every other engine I've tried. The relevant element in the xsd ogckml22.xsd;

<element name="LineStringSimpleExtensionGroup" type="anySimpleType" abstract="true"/>

and

    <complexType name="LineStringType" final="#all">
        <complexContent>
            <extension base="kml:AbstractGeometryType">
                <sequence>
                    <element ref="kml:extrude" minOccurs="0"/>
                    <element ref="kml:tessellate" minOccurs="0"/>
                    <element ref="kml:altitudeModeGroup" minOccurs="0"/>
                    <element ref="kml:coordinates" minOccurs="0"/>
                    <element ref="kml:LineStringSimpleExtensionGroup" minOccurs="0" maxOccurs="unbounded"/>
                    <element ref="kml:LineStringObjectExtensionGroup" minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

and an instance (relevant part only);

<LineString>
    <tessellate>1</tessellate>
    <gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
    <coordinates>3.32001280049665,6.572382963895447</coordinates>
    <LineStringSimpleExtensionGroup xsi:type="xsd:int">66</LineStringSimpleExtensionGroup>
</LineString>

Using VS2019 I get no validation errors. Using Stylus Studio and MSXML4/6 I get no validation errors. Using Stylus Studio and Java I get; (Error) cvc-elt.2: The value of {abstract} in the element declaration for 'LineStringSimpleExtensionGroup' must be false.

Running custom validation engine Saxonica 9.4.0.6 Validator...

Validation error at /kml[1]/Document[1]/Placemark[1]/LineString[1]/LineStringSimpleExtensionGroup[1] on line 150 column 55 of XtraElems.kml: In content of element : Invalid element : the element is declared to be abstract Validation of file file:///k:/Samples/XtraElems.kml unsuccessful.

This would seem to be correct, meaning all the microsoft parsers are incorrect? Surely not!

Bonus question - what on earth is the point of having all these elements in kml that are abstract if they can never be used? (and there are a LOT of them!)

walbury
  • 68
  • 5

1 Answers1

1

The Microsoft schema processor hasn't been updated for years. There are quite a few areas where they either chose to be non-conformant in the first place (for example they implement their own regex dialect rather than the W3C dialect), where bugs have been reported and not fixed, or where the spec has been clarified and they haven't updated their implementation. Quite a few of the test cases that Microsoft submitted to W3C -- which presumably their own processor passes -- have been challenged by other vendors and found to be incorrect.

The specs are clear (once you master the language!):

Validation Rule: Element Locally Valid (Element)

For an element information item E to be locally ·valid· with respect to an element declaration D all of the following must be true:
1 D is not ·absent· and E and D have the same expanded name.
2 D.{abstract} = false.
...

Basically, you can only be valid against an abstract element declaration if the declaration has a substitution group, and the element name matches a member of the substitution group. A classic example would be where a <history> element contains a sequence of abstract <event> elements, where the concrete event elements might be <birth>, <death>, <marriage> etc: because <event> is abstract, you can't use it directly, you can only use the concrete substitutions.

I'm not familiar with the KML schema design so I can't help you with that.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Being a Microsoft-stack developer for the last 20 or so years I was hoping that this wasn't going to be the case. No matter they are still fairly edge situations. Thanks for the corroboration. I wonder does this mean microsoft has given up on being a player in the entire XBRL space? (which is pretty much xsd dependant) I've just had another look at google's wrapper to kml (eg https://developers.google.com/kml/schema/kml22gx.xsd) and yes it does implement a few of these inner substitutionGroups so this would seem to be their purpose, extension hooks for other developers.Thanks again! – walbury Feb 15 '21 at 22:30