fix(YamlConverter): respect form="unqualified" on individual elements in getElementNamespace - #195
Open
XenosEleatikos wants to merge 1 commit into
Conversation
… in getElementNamespace When a schema has elementFormDefault="qualified" but an individual element explicitly declares form="unqualified", getElementNamespace incorrectly assigned a namespace to that element via the $schema->getElementsQualification() OR branch, overriding the element's own correct isQualified()=false result. The XÖV/XÖV-Standard xoev-code pattern relies on this distinction: all code/name child elements are declared form="unqualified" for cross-schema interoperability, even when the containing schema uses elementFormDefault="qualified". The fix removes $schema->getElementsQualification() from the condition entirely. $element->isQualified() already incorporates the schema-level default as a fallback when no explicit form attribute is present, so the removed condition was both redundant and incorrect. Reproducer: any XSD where elementFormDefault="qualified" and a local element has form="unqualified"; before this fix the generated JMS YAML metadata would include an erroneous namespace entry for that element.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
YamlConverter::getElementNamespaceassigns a namespace to an element even when that element explicitly declaresform="unqualified"in the XSD.The buggy condition:
When the containing schema has
elementFormDefault="qualified",$schema->getElementsQualification()returnstrue, which short-circuits the entire condition. This means an element that explicitly declaresform="unqualified"still gets anamespaceentry in the generated JMS YAML metadata — and is then serialized with a namespace prefix by JMS Serializer, violating the XSD contract.The xsd-reader correctly reads
form="unqualified"and callssetQualified(false)on the element. That correct result is silently overridden by the OR condition.Reproducer
XSD with
elementFormDefault="qualified"and a local element that overrides withform="unqualified":Generated YAML (wrong):
This causes JMS Serializer to produce
<ns:code>and<ns:name>instead of<code>and<name>, which validators reject.Fix
Remove
$schema->getElementsQualification()from the OR condition.$element->isQualified()already incorporates the schema-levelelementFormDefaultas a fallback when no explicitformattribute is present, so the removed check was both redundant and incorrect.Behaviour matrix
elementFormDefaultformattributequalifiedqualifiedform="unqualified"qualifiedform="qualified"unqualifiedunqualifiedform="qualified"