Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import ignored, when importing second XSD into the same namespace #1028

Open
jakubklimek opened this issue Oct 3, 2024 · 2 comments
Open

Comments

@jakubklimek
Copy link

I have this document and an XSD (linked from it from schemaLocation).

Now, the XSD imports 2 other XSDs with the same targetNamespace:

  <xs:import namespace="http://dia.gov.cz/ns/spolecne-casti-elektronickych-dokumentu/osoby" schemaLocation="https://ofn.gov.cz/společné-části-elektronických-dokumentů/2024-10-04/schémata/osoby/osoba-ve-vztahu-k-dokumentu.xsd"/>
  <xs:import namespace="http://dia.gov.cz/ns/spolecne-casti-elektronickych-dokumentu/osoby" schemaLocation="https://ofn.gov.cz/společné-části-elektronických-dokumentů/2024-10-04/schémata/osoby/fyzická-osoba-ve-vztahu-k-dokumentu.xsd"/>

The XSDs have both the same targetNamespace and contain no conflicting definitions. Nevertheless, the second import is ignored, resulting in an error:
{90310AA0-A8FD-4BC6-9C83-01261FF2DC72}

because that type is defined in the second imported XSD. When I comment out the first import, the second starts working.

This should be legal in XML Schema, and other validators like Altova work fine with it.

@angelozerr
Copy link
Contributor

angelozerr commented Oct 3, 2024

This error comes from xerces so I dont know if it is possible to fix it without some hack or perhaps it is a configuration of xerces.

Any contribution are welcome !

@jakubklimek
Copy link
Author

Just for the record, I investigated the XML Schema spec, and there is a note about this situation at the end of 4.2.6.2:

Given that the schemaLocation [attribute] is only a hint, it is open to applications to ignore all but the first for a given namespace, regardless of the ·actual value· of schemaLocation, but such a strategy risks missing useful information when new schemaLocations are offered.

Apparently, Xerces implementation indeed ignores all but the first import with a given namespace, resulting in exactly what the specification warns about - missing information, which then has to be provided by the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants