annotations on enumerations
Brought to you by:
dkuhlman
It appears from some quick debugging that generateDS.py is unable to handle enumerations that have their own annotations.
Specifically, when generateDS.py encounters elements such as L320 in IOF.xsd (github.com), this results in the element.values list not being populated when it comes to the XschemaHandler.characters method (sourceforge.net), so that L2039 gets an IndexError. If I comment out any instances of annotations-on-enumerations, generateDS.py runs fine.
The problem might come from an assumption that enumeration elements are not interrupted by other elements, I am not sure yet. If I manage to uncover more detail or to patch this myself I will of course share more.
Sorry! I populated some fields I think I should have left blank: Milestone and Labels
Martin,
Thanks for reporting this.
I believe your diagnosis is correct. It seems that this error
happens when the simpleType is anonymous and defines the type of
an attribute. In that case, the item we want to attach the
annotation does not yet exist. This error does not happen with a
named simpleType and it does not happen with an anonymous simpleType
that defines the type of an element in a complexType.
Attached is a patch that eliminates the exception. It causes us to
ignore the annotation in the case that causes the exception. These
annotations are only used to attach comments in the generated code.
I believe that there is still some work to be done related to this.
As far as I can tell, we are not generating an Enum class when we
have an anonymous simpleType that defines the type of an attribute.
I don't know whether we should or could. I'll look into it a bit
more and will report back in a day or two.
Dave
Martin,
I studied this a bit more, and I figured out why we were not
generating Enum classes when an anonymous
simpleTypewas used todefine an attribute: we were not raising those simple types to top level in
the schema as we were doing for the anonymous simple types used to
define elements (inside a
complexType). I made a fix, and now wedo (raise them to top level and give them names). So, now we do
generate Enum classes when a simple type contains a restriction that
contains enumerations.
And, as a bonus, this causes us to also generate code for
validation, which was formerly not being generated.
So, thanks again for reporting this and giving me a clue about the
problem. It resulted in several needed fixes.
Dave
Thanks for the quick investigation Dave! I can confirm that the new version, which I took from PyPI, reads
IOF.xsdperfectly. And I'm glad this prompted some needed fixes :-)