Restore 4 uniqueness removed in #998 where no xsd:key covers it (+ must-fail guards)#1032
Restore 4 uniqueness removed in #998 where no xsd:key covers it (+ must-fail guards)#1032thbar wants to merge 14 commits into
Conversation
(revert of 51b79ea for this constraint)
| </xsd:key> | ||
| <!-- =====GroupOfLinkSequences============================== --> | ||
| <!-- =====GroupOfLinkSequences unique========================== --> | ||
| <xsd:unique name="GroupOfLinkSequences_UniqueBy_Id_Version"> |
There was a problem hiding this comment.
Why do you think this is correct? For example, why isn't this just a key?
There was a problem hiding this comment.
See PR description (just added) ; I think it's more correct that what is in #998 on that specific bit, which was effectively removal of any sort of uniqueness check.
Why not key, well, key has been removed before v2.0.0 (see description). I don't know if adding it back in a patch release is a good idea or not, we'll have to discuss that collectively.
There was a problem hiding this comment.
@thbar and @skinkie,
I confirm that in v1.3, this part was written as follow:
<!-- =====GroupOfLinkSequences============================== -->
<!-- =====GroupOfLinkSequences unique========================== -->
<xsd:unique name="GroupOfLinkSequences_UniqueBy_Id_Version">
<xsd:annotation>
<xsd:documentation>Every [GroupOfLinkSequences Id + Version] must be unique within document.</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath=".//netex:GroupOfLinkSequences"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:unique>Direct link is this one.
Considering that GroupOfLinkSequencesRef is based on the substitution group VersionOfObjectRef and not TypeOfEntityRef, I am uncertain that a key will work.
However, let's make it simple and roll back to the original state of this part of the XSD.
Also, assert that the file cannot be considered valid, first and foremost.
ValidBetween lost (afaik) id+version uniqueness in 51b79ea and no xsd:key covers it (guarded by examples/should-fail/duplicate-ValidBetween.xml). Exact verbatim revert, byte-identical to v2.0. Its selector also covers ValidityCondition/ValidityTrigger/ValidityRuleParameter, which keys already cover - kept verbatim to stay an exact revert, not trimmed (but this can be covered by a later optimisation).
ValidityPeriod lost id+version uniqueness in 51b79ea and no xsd:key covers it (guarded by examples/should-fail/duplicate-ValidityPeriod.xml). Should be verbatim revert (compared to v2.0). Its selector also covers UsageValidityPeriod, which a key already covers - kept verbatim to stay an exact revert, not trimmed.
| </xsd:key> | ||
| <!-- ===== UsageValidityPeriod Key ========================== --> | ||
| <!-- ===== UsageValidityPeriodting unique========================== --> | ||
| <xsd:unique name="UsageValidityPeriod"> |
There was a problem hiding this comment.
It should be unique by key.
There was a problem hiding this comment.
See PR description, I'm just undoing problematic removal of any uniqueness at all, this is not a PR where I'm changing any unique to a key (and as commented above, at least one was removed just pre-v2.0.0, so it would be a bit confusing).
To be discussed, then (but this is not this PR's goal).
There was a problem hiding this comment.
A duplicate id is never correct, it is a key. Hence it should not be unique.
There was a problem hiding this comment.
Indeed, UsageValidityPeriod has both unique and key checked. So, the stand-alone key can remain.
XSD v1.3:
<!-- ===== UsageValidityPeriod Key ========================== -->
<!-- ===== UsageValidityPeriodting unique========================== -->
<xsd:unique name="UsageValidityPeriod">
<xsd:annotation>
<xsd:documentation>Every [UsageValidityPeriod Id + Version] must be unique within document.</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath=".//netex:UsageValidityPeriod | .//netex:ValidityPeriod"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:unique>
<xsd:keyref name="UsageValidityPeriod_KeyRef" refer="netex:UsageValidityPeriod_AnyVersionedKey">
<xsd:selector xpath=".//netex:UsageValidityPeriodRef"/>
<xsd:field xpath="@ref"/>
<xsd:field xpath="@version"/>
</xsd:keyref>
<xsd:key name="UsageValidityPeriod_AnyVersionedKey">
<xsd:selector xpath=".//netex:UsageValidityPeriod"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:key>Permalink to the XSD
|
@thbar read the comments. |
| </xsd:key> | ||
| <!-- =====ValidityCondition============================== --> | ||
| <!-- =====ValidityCondition unique========================== --> | ||
| <xsd:unique name="ValidityCondition_UniqueBy_Id_Version"> |
There was a problem hiding this comment.
This is worth a dedicated ticket (for this one & all the places deserving a key, either removed erroneously before v2.0.0 or not), and its own separate PR(s).
#1032 is just short rollback of 4 missing uniques.
There was a problem hiding this comment.
I think the opposite is true. It was erronousley added as unique, and the removal script removed id unique, because the expectation was a key must exist for an id.
There was a problem hiding this comment.
Yes, yet the key isn't there, so it creates a larger trouble even (no more unicity at all). We'll need to address that, so I created #1034 ; we'll catalogue over there.
There was a problem hiding this comment.
@thbar and @skinkie,
ValidityCondition has both the unique and key checked. So we can omit this roll-back.
XSD from v1.3 is as follow
<!-- =====ValidityCondition unique========================== -->
<xsd:unique name="ValidityCondition_UniqueBy_Id_Version">
<xsd:annotation>
<xsd:documentation>Every [ValidityCondition Id + Version] must be unique within document.</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath=".//netex:ValidityCondition | .//netex:ValidityTrigger | .//netex:ValidityRuleParameter | .//netex:ValidBetween"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:unique>
<!-- =====ValidityCondition Key ========================== -->
<xsd:keyref name="ValidityCondition_KeyRef" refer="netex:ValidityCondition_AnyVersionedKey">
<xsd:selector xpath=".//netex:ValidityConditionRef | .//netex:ValidityTriggerRef | .//netex:ValidityRuleParameterRef | .//netex:WithConditionRef"/>
<xsd:field xpath="@ref"/>
<xsd:field xpath="@version"/>
</xsd:keyref>
<xsd:key name="ValidityCondition_AnyVersionedKey">
<xsd:selector xpath=".//netex:ValidityCondition | .//netex:ValidityTrigger | .//netex:ValidityRuleParameter | .//netex:AvailabilityCondition"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:key>
This is the permalink.
| </xsd:key> | ||
| <!-- =====GroupOfLinkSequences============================== --> | ||
| <!-- =====GroupOfLinkSequences unique========================== --> | ||
| <xsd:unique name="GroupOfLinkSequences_UniqueBy_Id_Version"> |
There was a problem hiding this comment.
@thbar and @skinkie,
I confirm that in v1.3, this part was written as follow:
<!-- =====GroupOfLinkSequences============================== -->
<!-- =====GroupOfLinkSequences unique========================== -->
<xsd:unique name="GroupOfLinkSequences_UniqueBy_Id_Version">
<xsd:annotation>
<xsd:documentation>Every [GroupOfLinkSequences Id + Version] must be unique within document.</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath=".//netex:GroupOfLinkSequences"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:unique>Direct link is this one.
Considering that GroupOfLinkSequencesRef is based on the substitution group VersionOfObjectRef and not TypeOfEntityRef, I am uncertain that a key will work.
However, let's make it simple and roll back to the original state of this part of the XSD.
| </xsd:key> | ||
| <!-- =====ValidityCondition============================== --> | ||
| <!-- =====ValidityCondition unique========================== --> | ||
| <xsd:unique name="ValidityCondition_UniqueBy_Id_Version"> |
There was a problem hiding this comment.
@thbar and @skinkie,
ValidityCondition has both the unique and key checked. So we can omit this roll-back.
XSD from v1.3 is as follow
<!-- =====ValidityCondition unique========================== -->
<xsd:unique name="ValidityCondition_UniqueBy_Id_Version">
<xsd:annotation>
<xsd:documentation>Every [ValidityCondition Id + Version] must be unique within document.</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath=".//netex:ValidityCondition | .//netex:ValidityTrigger | .//netex:ValidityRuleParameter | .//netex:ValidBetween"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:unique>
<!-- =====ValidityCondition Key ========================== -->
<xsd:keyref name="ValidityCondition_KeyRef" refer="netex:ValidityCondition_AnyVersionedKey">
<xsd:selector xpath=".//netex:ValidityConditionRef | .//netex:ValidityTriggerRef | .//netex:ValidityRuleParameterRef | .//netex:WithConditionRef"/>
<xsd:field xpath="@ref"/>
<xsd:field xpath="@version"/>
</xsd:keyref>
<xsd:key name="ValidityCondition_AnyVersionedKey">
<xsd:selector xpath=".//netex:ValidityCondition | .//netex:ValidityTrigger | .//netex:ValidityRuleParameter | .//netex:AvailabilityCondition"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:key>
This is the permalink.
| </xsd:key> | ||
| <!-- ===== UsageValidityPeriod Key ========================== --> | ||
| <!-- ===== UsageValidityPeriodting unique========================== --> | ||
| <xsd:unique name="UsageValidityPeriod"> |
There was a problem hiding this comment.
Indeed, UsageValidityPeriod has both unique and key checked. So, the stand-alone key can remain.
XSD v1.3:
<!-- ===== UsageValidityPeriod Key ========================== -->
<!-- ===== UsageValidityPeriodting unique========================== -->
<xsd:unique name="UsageValidityPeriod">
<xsd:annotation>
<xsd:documentation>Every [UsageValidityPeriod Id + Version] must be unique within document.</xsd:documentation>
</xsd:annotation>
<xsd:selector xpath=".//netex:UsageValidityPeriod | .//netex:ValidityPeriod"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:unique>
<xsd:keyref name="UsageValidityPeriod_KeyRef" refer="netex:UsageValidityPeriod_AnyVersionedKey">
<xsd:selector xpath=".//netex:UsageValidityPeriodRef"/>
<xsd:field xpath="@ref"/>
<xsd:field xpath="@version"/>
</xsd:keyref>
<xsd:key name="UsageValidityPeriod_AnyVersionedKey">
<xsd:selector xpath=".//netex:UsageValidityPeriod"/>
<xsd:field xpath="@id"/>
<xsd:field xpath="@version"/>
</xsd:key>Permalink to the XSD
Scope of this PR
xsd:keyenforces the uniqueness:GroupOfLinkSequences,OperatingDay,ValidBetweenandValidityPeriod.examples/should-fail/) that prove the uniqueness is no longer enforced — we can decide later what to do with them (e.g. keep them as permanent CI guards).This PR restores the missing
xsd:unique— otherwisev2.0.1would not be a correct optimisation, since it would silently drop validation thatv2.0.0had (these four were enforced inv2.0.0viaxsd:unique).It does not replace them with
xsd:key. ForGroupOfLinkSequences, afaikxsd:keywas there beforev2.0.0, but has removed by #721/#462 beforev2.0.0was released (which is why it's important to avoid also removing unique here).Whether to (re)introduce keys is a separate discussion we can have, but not the scope of this PR (and maybe not for a
v2.0.1bug fix either).