-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Generate classes for element groups #962
Comments
Groups of elements are flattened @skinkie so it becomes a choice of two sequences |
Which is obviously not what was intended. What should be used if I would like to see them as a choice between two sets of elements? |
When reading the code the code now flattens groups, and then removes them. I have created this rather simple form of the use case. <?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.netex.org.uk/netex" xmlns:netex="http://www.netex.org.uk/netex" xmlns:siri="http://www.siri.org.uk/siri" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.netex.org.uk/netex" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1" id="netex_datedPassingTimes_version">
<xsd:element name="Test">
<xsd:complexType>
<xsd:sequence>
<xsd:choice>
<xsd:group ref="TargetTimesAtStopGroup">
<xsd:annotation>
<xsd:documentation>Aimed Times at stop.</xsd:documentation>
</xsd:annotation>
</xsd:group>
<xsd:group ref="NonStopTimesAtStopGroup"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:group name="TargetTimesAtStopGroup">
<xsd:annotation>
<xsd:documentation>Times at stop elements.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="AimedArrivalTime" type="xsd:time" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Aimed Arrival time.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="AimedDepartureTime" type="xsd:time" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Aimed departure time.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="AimedWaitingTime" type="xsd:duration" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Aimed waiting interval.</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:group>
<xsd:group name="NonStopTimesAtStopGroup">
<xsd:annotation>
<xsd:documentation>Times at stop elements.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="AimedNonstopPassingTime" type="xsd:time" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Aimed PASSING TIME if doesn't stop at TIMING POINT.</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:group>
</xsd:schema> I am looking for something like this as the output:
I guess for this to happen the analyser should mark groups within a choice as something special, to later upgrade them into a type which would get its own class. |
Yeah and the xml parser/serializer has to recognize and ignore the group classes. We would need to implement something like the wrappers but for groups. Honestly I don't like the approach. xsdata philosophy is to simplify xml schemas not replicate all their quirks into python. Some of them like circular references would be impossible to tackle otherwise. I am going to leave this issue open as a feature request, but don't hold your breath. |
Thanks, I'll investigate.
My aim for this project would be to have an object-oriented output of an XML Schema. The flattening is, where there is more than one group, does not do just to the XML Schema in this particular case. I can find some other cases where it certainly makes sense to flatten it. (AllSubModeChoiceGroup)
I have just researched how and when this is done within the NeTEx schema, it is not that often. |
I have zero interest in this one, it goes against the architecture of the cli to always simplify the generated models. Although If someone manages to implement it behind a configuration flag, I will gladly accept the contribution |
I am currently reviewing the output of the ambigious branch and main and I notice something odd. Consider the TargetTimesAtStopGroup. I really believe this is not right.
Source file
./xsd/netex_part_2/part2_journeyTimes/netex_datedPassingTimes_version.xsd
This should become something like a choice between two types. But instead each element becomes part of the choice.
This becomes:
The text was updated successfully, but these errors were encountered: