-
Notifications
You must be signed in to change notification settings - Fork 72
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
Exceeded recursion depth with multiple schema locations for namespaces not matching targetNamespace
of referenced schemas
#324
Comments
Hi, this is strictly related to locations argument when an imported schema has a different targetNamespace than the one declared in locations argument. To solve this i will filter out imported namespace from Thank you |
Thanks, I made some local adjustments in I also spent a bit more time wading through the XML Schema specs but I still couldn't find anything that explicitly says that the namespace being pointed to a schema in Do you know where this behaviour would be more explicitly specified or how other validators handle this namespace issue? My impression from searching around gave me the impression that this is not uniformly handled across available tools, but I might be wrong. |
Thank you, but I already made the changes in my develop. In locations=[x for x in self._locations if x[0] != namespace]
For Using
I will build a test case for checking this and try it also with other software. |
Yeah, for I tested locally with 2 validating environments I had available easily:
Would be interesting to see how Saxon or Oxygen validate this if you have access to them. Thanks for looking into it! |
The complexity is on removing a schema after import if it has a different namespace than expected. The imported schema can have its
I tested with an online validator based on Xerces-J and assessed as valid only if there is an explicit import in the origin schema, so xsi location hints in XML are ignored. But looking at Xerces-J source and some comments this behavior is configurable and LemMinX may not use the default setting.
Also testing with xmllint give me errors, but looking at source code in libxml2 this should be be possible when non schema is provided. In this case it should be an interface limitation, that requires a schema instance to do validation.
I will try Saxon-HE (that is open-source) using the python interface, also in this case the usage of XSI location hints should be an option. Probably i will make optionable this also for xmlschema's document API (e.g. |
After a check in Definitive XML Schema i can confirm that if a schema is retrieved using a XSI schema location hint its targetNamespace must match the namespace paired with the location. The usage of XSI location hints is not mandatory and depends by the implementation. Currently xmlschema uses XSI schema location hints when a schema istance is not already available. I add the optional argument |
Hi @prettyv, a fix is available with release v2.0.4. Namespace mismatch still generates an import error. This is the correct behavior. If you need to create a schema with non-standard import, create the schema instance providing a list of sources or a list of locations and In v2.0.4 I have also added the option Best regards |
When an XML document specifies multiple schema locations in its
xsi:schemaLocation
attribute with namespaces that don't match the namespace defined in thetargetNamespace
attribute of the schema there is infinite recursion.Minimal example to reproduce:
When there is only one namespace mismatch I at least get an
XMLSchemaParseError: cannot import namespace 'http://www.w3.org/1999/xlink': imported schema 'http://www.loc.gov/standards/mix/mix.xsd' has an unmatched namespace 'http://www.loc.gov/standards/mix/'
.I ran into this when trying to simply instantiate a
XmlDocument
from a METS file that was produced by Goobi Workflow with a root element like this:I'm not sure if a mismatch like this is even really supposed to be an error according to the XML Schema specifications after an admittedly quick glance at them. Even so, there definitely shouldn't be infinite recursion if there are multiple, but since I'm not familiar with the codebase I wasn't able to find an obvious fix yet.
Tested in a venv with the current v2.02 under Python 3.10.6 on Arch Linux.
The text was updated successfully, but these errors were encountered: