-
Notifications
You must be signed in to change notification settings - Fork 75
Circular dependencies in schemas causing AttributeError #101
Comments
FWIW, Altova XMLSpy is able to validate a sample file using the |
I don't know how you generate the bindings; my second attempt was with the following, which worked with some warnings about lack of information for imported namespaces that might be eliminated by changing the order of generation. Theoretically PyXB sorts the dependencies for anything generated in the same invocation and performs resolution bottom up, so it should handle anything that isn't a true circular dependency (which I believe would be invalid). Without a document to parse I can't tell if this works.
|
Thanks so much for the quick reply. Sorry if I was unclear, I was able to generate the bindings, but when I try to use |
You weren't unclear, just incomplete. You identified a problem parsing a document, but didn't provide a document I could use to reproduce the problem. It would save time in the future if you would provide:
I made a script that imported the modules generated by the script I showed in that same order. Running it produces the following:
Is that the sort of error you see? PyXB does try to impose a strict order where types are defined before they're referenced, and puts all those types into a file where the order is satisfied (in this case, With "sane" schema one can often generate the bindings for related namespaces in smaller groups that form a strongly-connected component; see this example. Maybe that can be done based on prefixes of your namespaces. Then you build additional namespaces using PyXB's archive facility to load in the metadata describing the binding content. The opengis bundle as a whole may be a useful example. However, this is only supposed to be needed to reduce the size of individual generated binding files. So in short, this should work, if you can generate the bindings in sets that have self-contained cross-namespace dependency loops, and no true loops at the individual type level (e.g. group models that contain elements that contain the group, though in some cases that can be made to work). If the loops are inherent in the information structures you'll need to find another solution. |
I am getting an AttributeError in
_nsgroups.py
when trying to parse a document from the bindings generated for the attached schema. It seems to be related to circular dependencies in the source schemas (which are auto-generated).I am just looking for some guidance on whether PyXB supports handling schemas with circular dependencies and/or if there is some trick to generating the bindings, or if I need to completely refactor the source schema to get it to work.
I have attached a zip of the source schema. Thanks in advance for any guidance.
regxml.zip
The text was updated successfully, but these errors were encountered: