ITxPT/DATA4PTTools

Authority::Locale raised as error by xsd validation

Closed this issue · 2 comments

I'm getting the following XSD validation error for the file below, which at first sight seems correct to me and to my understanding of the XSD:

Element 'Locale': This element is not expected. Expected is one of ( PrivateContactDetails, OrganisationType, typesOfOrganisation, Status, ValidityPeriod, parts, ownResponsibilitySets, delegatedResponsibilitySets, delegatedFrom, relatedOrganisations ).

The faulty part is (extract of the relevant section):

                <ResourceFrame version="any" id="FOO:ResourceFrame:0">
                    <organisations>
                        <Authority version="any" id="FOO:Authority:1">
                            <Name lang="fr">FOO</Name>
                            <ContactDetails>
                               <Phone>0102030405</Phone>
                               <Url>https://www.foo.com</Url>
                            </ContactDetails>
                            <Locale>
                                <TimeZone>Europe/Paris</TimeZone>
                                <DefaultLanguage>fr</DefaultLanguage>
                            </Locale>
                        </Authority>
                    </organisations>
                </ResourceFrame>

Reading the Netex 1.2.2 generated Java binding classes, the "rest" field of the "Organisation_VersionStructure" can refer to "Locale" in it's list. The XML above is generated using the binding classes + JAXB.

Is it a faulty interpretation of the specs? Or a bug in the validator?

Note 1: I'm using a 1.2.2 version to generate the XML, however the XSD part of the relevant section from my validator is exactly the same as the one I'm using to generate the file.

Note 2: The validation error is raised by both the latest docker image and the online validator.

From what I have gathered reading https://github.com/ITxPT/DATA4PTTools/blob/develop/xsd/netex/1.2/netex_framework/netex_genericFramework/netex_organisation_version.xsd#L254, the order is important (given <xsd:sequence>), the elements must appear in the same order as in the definition i.e. swapping the place of <ContactDetails> and <Locale> should fix the issue.

Working example

<ResourceFrame version="any" id="FOO:ResourceFrame:0">
  <organisations>
    <Authority version="any" id="FOO:Authority:1">
      <Name lang="fr">FOO</Name>
        <Locale>
          <TimeZone>Europe/Paris</TimeZone>
          <DefaultLanguage>fr</DefaultLanguage>
        </Locale>
        <ContactDetails>
          <Phone>0102030405</Phone>
          <Url>https://www.foo.com</Url>
        </ContactDetails>
    </Authority>
  </organisations>
</ResourceFrame>

Indeed, that solved the issue. The generated java binding classes does not enforce the fact that the order matters.