Skip to content
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

Abstract stuff has not fully been filtered #629

Closed
skinkie opened this issue Nov 28, 2021 · 6 comments · Fixed by #633
Closed

Abstract stuff has not fully been filtered #629

skinkie opened this issue Nov 28, 2021 · 6 comments · Fixed by #633

Comments

@skinkie
Copy link
Contributor

skinkie commented Nov 28, 2021

From the NeTEx schema;

@dataclass
class Route2(LinkSequenceVersionStructure):
    """
    Dummy supertype for Route.
    """
    class Meta:
        name = "Route_"
        namespace = "http://www.netex.org.uk/netex"
    <xsd:element name="Route_" type="LinkSequence_VersionStructure" abstract="true" substitutionGroup="LinkSequence">
        <xsd:annotation>
            <xsd:documentation>Dummy supertype for Route.</xsd:documentation>
        </xsd:annotation>
    </xsd:element>
@tefra
Copy link
Owner

tefra commented Nov 28, 2021

The filter I applied was for the field type annoations, not from generating those abstract classes

@skinkie
Copy link
Contributor Author

skinkie commented Nov 28, 2021

The filter I applied was for the field type annoations, not from generating those abstract classes

Would it be feasible to filter them as well?

@tefra
Copy link
Owner

tefra commented Nov 28, 2021

I am open to suggestions, other schemas actually depend on abstract types

@skinkie
Copy link
Contributor Author

skinkie commented Nov 28, 2021

I am open to suggestions, other schemas actually depend on abstract types

How do they depend on them? Are they instantiated from an abstract type?

@tefra
Copy link
Owner

tefra commented Nov 28, 2021

The are used as extensions:

	<xs:complexType name="GlobalDateTimeType">
		<xs:complexContent>
			<xs:extension base="DateTimeType">
				<xs:attribute name="DateTime" type="IntDateTime" use="required">
					<xs:annotation>
						<xs:documentation>This date should be of the form YYYY-MM-DDTHH:MM:SS.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="DateTimeType" abstract="true">
		<xs:attribute name="TimeWindowStart" type="TimeWindowBoundaryType">
			<xs:annotation>
				<xs:documentation>Allowed amount of time before specified time.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="TimeWindowEnd" type="TimeWindowBoundaryType">
			<xs:annotation>
				<xs:documentation>Allowed amount of time after specified time.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		...
		...
		...

One idea would be to go around and filter completely unused abstract types, because that's really your use case...

Netex is using the abstract elements as placeholders for substitution groups, which works but I am not sure if that was a goal of the design of xsd

@tefra
Copy link
Owner

tefra commented Dec 4, 2021

Thanks for reporting @skinkie I added a more strict check as to what models should be generated, now only global non abstract types will be generated and any complex type, or enumerations that are actually referened in the other models

That should remove another ~2k lines from the netex output 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants