-
Notifications
You must be signed in to change notification settings - Fork 45
First referencing class constraints #962
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
Conversation
This is the first working attempt to add additional information to NeTEx references, enabling access to the class that each reference points to. The implementation processes all VersionOfObjectRefStructure variants and builds a hierarchical tree of them. This allows defining defaults, for example, a ScheduledStopPointRef normally points to a ScheduledStopPoint. If it instead points to a FareScheduledStopPoint, this is validated and allowed, because FareScheduledStopPoint is a descendant of ScheduledStopPoint. The reverse, however, is not allowed: a TimingPoint cannot be referenced by a ScheduledStopPointRef. There are several issues that still need to be addressed. Therefore, this implementation deliberately takes an incremental approach rather than aiming for a 100% complete solution, especially since the NeTEx XML Schema itself is not fully consistent or correct. The complex-types-included file is generated by a script that computes all *Ref elements ultimately derived from VersionOfObjectRefStructure. For these elements, all associated complex types are extracted and stored in complex-types-included. There is also a negative list, complex-types-excluded. During development of this feature, it became clear that several complex types or cascades caused issues; instead of fixing hundreds of validation errors immediately, this list allows us to focus on the positive results of the working cases first. In addition to the exclusion list, the script/nameofclass.py logic skips variants for which no clear relationship can be found between a reference and its corresponding class. Given the number of references now correctly resolved, it is clear how valuable this approach is and why it should be further pursued to reduce the exclusion list over time.
|
@skinkie |
When we do the hygiene we should stop using Ref for free textin the same go. |
Agree, but as said it might be considered as breaking change and not just hygiene by some |
|
@TuThoThai I do not see how your comment is related to this pull request. |
This still required some manual intervention for both PlaceRef as AuthorityRef. Will fix the automatic processing later (if possible).
|
@skinkie |
|
It does not break anything, because all examples are validated (and repaired). |
The script included all xsd sub-folders, but the examples naively referenced classes without any prefixed. For GML we now have explicitly added them (manually) to the script, with the gml: prefix. The examples were updated accordingly. This significantly reduces the enumerations, and reduces them to NeTEx only (without prefix). In addition substitutionGroups 'results' have been added to the enumeration of the classes.
|
Release meeting as of 9 Oct 2025:
Deadline: 14 Oct 2025 |
trurlurl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to put the automatically generated files in a separate folder or to otherwise signal that no manual editing is necessary? Or are the scripts only run sporadically?
|
Small point; PR make even more mandatory to have a "How to add an Element to NeTEx" to be available here inn the repo (not in the CEN Doc). There was already the xxxIdType, xxxx_VersionStructure, xxxGroup, xxxRef, xxxRefStructure, xxxRefs_RelStructure, etc. we now have that huge NameOfClass and authorised ref classes details which are in a totally separated file (netex_entity_support.xsd). Maybe we need a kind of plan to maintain in (it's likely that people will forget to update it). |
TuThoThai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with the general comment that whenever the documentation stays "Automatic reference class for" means it has been added via the script (i.e., automatically generated).
This is for future general documentation purpose on this repo (most probably via Wiki)
|
@skinkie I will review that too. Can you confirm all the commits are out and pushed, and the PR is stable for review? Thanks! |
@trurlurl This is not really possible, because the most parts that are changed are part of regular objects.
@Aurige I don't know if I send someone an email on exactly this point yesterday, but I totally agree. Especially the extension / restriction point is now a choice made. That should be documented with what, how and why.
@Aurige Do you mean it should actually be included with imports, or was that already the case?
@TuThoThai Update to Automatically generated scheduled.
@thbar maybe if the IdTypes is fastly implemented I might update the python script to be more correct. The few missing classes could be included. But I am not going for the 1% if the 99% is what we want to fix today. |
@skinkie, ok for me and duly noted on your comments. |
thbar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 🚀
Great work adding better typing & structure @skinkie.
Since I don't want to delay the merge: I'll do later (before final release) some testing against live data files, as mentioned in #963 (and in the future, will make sure I can do it at the PR review level more easily, with adequate tooling).
Suggestion: I feel the PR title & TL;DR could be updated (If I understand well) to better reflect the improvements (e.g. stronger typing, or any typing at all etc) & make it easier to prepare release notes later. But that's not a blocker given the amount of things already merged in 😄
thbar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approving (only change is without impact).
|
For the Idfixes I updated some other code too, but you'll see. |
@skinkie code that you will push on this PR & we must add to the review? (or that you'll push elsewhere?) (asking since @TuThoThai was more or less about to merge in the current state, last time we discussed) |
|
For the reader - the other code is at: Moving forward! |
Description
This is the first working attempt to add additional information to NeTEx references, enabling access to the class that each reference points to. The implementation processes all VersionOfObjectRefStructure variants and builds a hierarchical tree of them. This allows defining defaults — for example, a ScheduledStopPointRef normally points to a ScheduledStopPoint.
If it instead points to a FareScheduledStopPoint, this is validated and allowed, because FareScheduledStopPoint is a descendant of ScheduledStopPoint. The reverse, however, is not allowed: a TimingPoint cannot be referenced by a ScheduledStopPointRef.
There are several issues that still need to be addressed. Therefore, this implementation deliberately takes an incremental approach rather than aiming for a 100% complete solution, especially since the NeTEx XML Schema itself is not fully consistent or correct.
How to review
The individual commits should be review stepping stones, then you understand why what happens.
The big issue with the current approach was that there wasn't a uniform way how reference-classes were implemented. My suggestion for documentation (hint: @TuThoThai) is that we describe why reference classes should virtually always be a restriction, embedded in simpleContent. We don't extend references (ref, version, nameofrefclass, uri, etc.) but we restrict their types. Using extension element anywhere in this graph makes the leaf impossible. So convert the few remaining extensions, to restrictions like the rest. 237fe94
For some reasons (let it be named: everything was done by hand, no validations in place, merge conflicts) we ended up with references to classes that do not exist, and maybe never did. NeTEx 3.0 will remove that stuff, but for now, we don't break what is in there, but also not let it break us. 76a7648
Next step goes one step further, and just removes the default attributes on all places that suggests a NameOfClass that was, or has never been a class. For complaints: fix this stuff yourself, nobody could use it anyway. 477677c
My personal believe is that NameOfClass in any case has been very under defined. Was the meaning "all elements", was it just EntityInFrame, nobody knows, but considering its use all was mixed. This commit creates the NameOfClass structure automatically. And fixes all examples, including crazy profile definitions that were never matching the NameOfClass definition in the first place. f7cd256
Last step. The actual implementation of applying nameOfRefClass to all references that did not complain, and fix all the examples that were invalid. We should have a discussion on the excludelist.
How it works
The complex-types-included file is generated by a script that computes all *Ref elements ultimately derived from VersionOfObjectRefStructure. For these elements, all associated complex types are extracted and stored in complex-types-included. There is also a negative list, complex-types-excluded. During development of this feature, it became clear that several complex types or cascades caused issues; instead of fixing hundreds of validation errors immediately, this list allows us to focus on the positive results of the working cases first.
In addition to the exclusion list, the script/nameofclass.py logic skips variants for which no clear relationship can be found between a reference and its corresponding class.
Given the number of references now correctly resolved, it is clear how valuable this approach is and why it should be further pursued to reduce the exclusion list over time.
Urgency: High
@TuThoThai I would like you to make sure that this pull request is reviewed and merged as soon as possible. My preference would be regular merge (non-squash).