Comments (5)
Groups of elements are flattened @skinkie so it becomes a choice of two sequences
from xsdata.
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?
from xsdata.
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:
"choices": (
{
"name": "TargetTimesAtStopGroup",
"type": Type[
"TargetTimesAtStopGroup"
],
"namespace": "http://www.netex.org.uk/netex",
},
{
"name": "NonStopTimesAtStopGroup",
"type": Type[
"NonStopTimesAtStopGroup"
],
"namespace": "http://www.netex.org.uk/netex",
},
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.
from xsdata.
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.
from xsdata.
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.
Thanks, I'll investigate.
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.
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 am going to leave this issue open as a feature request, but don't hold your breath.
I have just researched how and when this is done within the NeTEx schema, it is not that often.
NeTEx-CEN/NeTEx#669
from xsdata.
Related Issues (20)
- Check type hinting, extra parentheses for attribute. HOT 6
- Recursion Limit Reached HOT 3
- extending the SOAP Config NamedTuple... HOT 5
- Do not lose data during serialization after parsing HOT 5
- Parsing XML to a class: A sequence of alternatives is wronly parsed HOT 2
- WSDL generation gets overwritten by imported XSD of the same name HOT 1
- self-referencing field - original case recursion error HOT 1
- Question about preferred way of XML parsing HOT 4
- Lxmltreeserializer str versus list HOT 5
- Errors lxmlserializer HOT 5
- Rewrite tree serializers to utilize the existing event writers
- SOAP: Stubs are not generated for most operations in EJBCA WSDL HOT 2
- Ability to capture namespace mappings on code generation, and render xml with the same mappings HOT 2
- Access unknown attributes HOT 2
- Improve converter/parser errors HOT 1
- Rename (abstract) objects HOT 2
- Generate full XML examples from given schema HOT 1
- For unions the types are more elegant HOT 14
- `Error: Cross reference detected` for unused complex types HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xsdata.