Comments (14)
I don't follow @skinkie 🥲
from xsdata.
scheduled_stop_point_ref becomes FareScheduledStopPointRef | ScheduledStopPointRef
onward_timing_link_ref becomes TimingLinkRefStructure
I would like to see onward_timing_link_ref as TimingLinkRef.
I don't see what in the XML Schema causes this distinction. Why wouldn't scheduled_stop_point_ref become FareScheduledStopPointRefStructure | ScheduledStopPointRefStructure?
from xsdata.
I don't understand the comparison, in both cases the generator behaves exactly the same, which is avoid flattening global types (root level elements and complex types.)
scheduled_stop_point_ref
gets ScheduledStopPointRef
from <xsd:element ref="ScheduledStopPointRef"/>
The scheduled_stop_point_ref
also gets FareScheduledStopPointRef
from
<xsd:element name="FareScheduledStopPointRef" type="FareScheduledStopPointRefStructure" substitutionGroup="ScheduledStopPointRef">
onward_timing_link_ref
gets OnwardTimingLinkRef
from
<xsd:element name="OnwardTimingLinkRef" type="TimingLinkRefStructure" minOccurs="0">
from xsdata.
I don't understand the comparison, in both cases the generator behaves exactly the same, which is avoid flattening global types (root level elements and complex types.)
scheduled_stop_point_ref
getsScheduledStopPointRef
from<xsd:element ref="ScheduledStopPointRef"/>
So you say that if
<xsd:element name="OnwardTimingLinkRef" type="TimingLinkRefStructure" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Onward link - used to disambiguate if there are multiple links from the same stop, e.g. as for cloverleaf route topology. If not given explicitly assume there is only one link that connects the two.</xsd:documentation>
</xsd:annotation>
</xsd:element>
would be replaced by:
<xsd:element ref="OnwardTimingLinkRef" />
<xsd:element name="OnwardTimingLinkRef" type="ScheduledStopPointRefStructure" substitutionGroup="TimingPointRef">
<xsd:annotation>
<xsd:documentation>Onward link - used to disambiguate if there are multiple links from the same stop, e.g. as for cloverleaf route topology. If not given explicitly assume there is only one link that connects the two.</xsd:documentation>
</xsd:annotation>
</xsd:element>
It would make TimingLinkRef (as type) out of it?
My ideal would be that the TimingLinkRef is used, I noticed that also xmlspy and likes take the RefStructure, so it is likely something in the schema. The user must use TimingLinkRef (and not TimingLinkRefStructure) as type.
(I corrected some typo's in this post)
from xsdata.
No I didn't say that 😄 xsdata can't go around flattening global types, that's what it does in both cases. We can't replace the child types with parent types just because, technically we could, but that would force the serializer to add the xsi:type to reveal the real type in order to pass schema validations.
The whole structure is maddening, all that for no good reason, the restriction basically does nothing, except creating a lot of clones.
<xsd:element name="TimingLinkRef" type="TimingLinkRefStructure" substitutionGroup="LinkRef" />
<xsd:complexType name="TimingLinkRefStructure">
<xsd:simpleContent>
<xsd:restriction base="LinkRefStructure">
<xsd:attribute name="ref" type="TimingLinkIdType" use="required"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="LinkRefStructure">
<xsd:simpleContent>
<xsd:restriction base="VersionOfObjectRefStructure">
<xsd:attribute name="ref" type="LinkIdType" use="required">
<xsd:annotation>
<xsd:documentation>Identifier of a LINK.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="LinkIdType">
<xsd:restriction base="ObjectIdType"/>
</xsd:simpleType>
<xsd:complexType name="VersionOfObjectRefStructure">
<xsd:annotation>
<xsd:documentation>Type for a versioned reference to a NeTEx Object.</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="ObjectIdType">
...
<xsd:attribute name="ref" type="ObjectIdType" use="required" />
from xsdata.
No I didn't say that 😄 xsdata can't go around flattening global types, that's what it does in both cases. We can't replace the child types with parent types just because, technically we could, but that would force the serializer to add the xsi:type to reveal the real type in order to pass schema validations.
But in this case TimingLinkRefStructure is the parent of TimingLinkRef? The problem is indeed that if the user wrongfully uses TimingLinkRefStructure (like xsdata suggests) it ends up with the xsi:type (so it is also to avoid user error).
The whole structure is maddening, all that for no good reason, the restriction basically does nothing, except creating a lot of clones.
I think the only reason the structure does this, is to create an unique IdType.
from xsdata.
Can you show me an example, because I don't see that in the samples @skinkie,
TimingLinkRefStructure
is the child not the parent
from xsdata.
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig
from netex import StopPointInJourneyPattern, TimingLinkRefStructure
spijp = StopPointInJourneyPattern(onward_timing_link_ref=TimingLinkRefStructure(ref="test")) # This is based on type hinting in PyCharm.
ns_map={'': 'http://www.netex.org.uk/netex', 'gml': 'http://www.opengis.net/gml/3.2'}
serializer_config = SerializerConfig(ignore_default_attributes=True)
serializer_config.pretty_print = True
serializer_config.ignore_default_attributes = True
serializer = XmlSerializer(serializer_config)
print(serializer.render(spijp, ns_map))
It is not that bad in Python it seems :-)
<?xml version="1.0" encoding="UTF-8"?>
<StopPointInJourneyPattern xmlns="http://www.netex.org.uk/netex" xmlns:gml="http://www.opengis.net/gml/3.2">
<OnwardTimingLinkRef ref="test"/>
</StopPointInJourneyPattern>
But considering that we want people to use TimingLinkRef (and not TimingLinkRefStructure) the question is: what to do?
from xsdata.
TimingLinkRefStructure
is the child not the parent
I would say no?
@dataclass(kw_only=True)
class TimingLinkRef(TimingLinkRefStructure):
class Meta:
namespace = "http://www.netex.org.uk/netex"
from xsdata.
I am sorry I was comparing this TimingLinkRefStructure(LinkRefStructure)
, netex is not the simplest suite to follow
But considering that we want people to use TimingLinkRef (and not TimingLinkRefStructure) the question is: what to do?
I don't know 😄, update the schema? I can't help with that, why do you even want that, to generate the xsi:type?
from xsdata.
But considering that we want people to use TimingLinkRef (and not TimingLinkRefStructure) the question is: what to do?
I don't know 😄, update the schema? I can't help with that, why do you even want that, to generate the xsi:type?
I don't want to have the xsi:type. I would like to see the typehint TimingLinkRef. So someone would naively do this:
spijp = StopPointInJourneyPattern(onward_timing_link_ref=TimingLinkRef(ref="test"))
from xsdata.
Ok so you want all the children of the TimingLinkRefStructure
to appear in the type hint
TimingLinkRef
ServiceLinkRefStructure
ServiceLinkRef
Understandable, but very difficult to accomplice @skinkie as far as I know no-other schema code generator does this...
from xsdata.
Ok so you want all the children of the TimingLinkRefStructure to appear in the type hint
It is clear you look at least 3 steps ahead of my question.
Understandable, but very difficult to accomplice @skinkie as far as I know no-other schema code generator does this...
To be fair. xsData is the best schema generator ever built. I wonder why it took 20 years to appear ;-)
from xsdata.
I think for this specific question the OnwardTimingLink is not a 'substitution group kind of thing', and it should not do what I ask. I'll come back with a specific example iff there exists one.
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
- Generate classes for element groups HOT 5
- 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
- `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.