Fix: xs:element default value ignored for simpleContent extension types - #285
Draft
Bergmann89 with Copilot wants to merge 2 commits into
Draft
Fix: xs:element default value ignored for simpleContent extension types#285Bergmann89 with Copilot wants to merge 2 commits into
Bergmann89 with Copilot wants to merge 2 commits into
Conversation
Thread `default` attribute from xs:element through meta-model, generator, and renderer to produce `default_content()` and use it in the generated deserializer for `Event::Empty` (self-closing element with no text content). Changes: - ComplexMeta: add `default: Option<String>` field - Interpreter: propagate xs:element `default` to inline ComplexMeta - Generator: pass default through to ComplexDataContent as ValueRendererBox - Renderer (defaults.rs): render `default_content()` method - Renderer (deserialize.rs): intercept Event::Empty and use default_content() - New feature test for xs:boolean + simpleContent default - Update ONIX expected output (also has an element with default)
Copilot
AI
changed the title
[WIP] Fix issue with xs:boolean element ignoring default value
Fix: xs:element default value ignored for simpleContent extension types
Jul 24, 2026
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.
When an
xs:elementcarriesdefault="false"and wraps an inline complex type withxs:simpleContent(e.g. extendingxs:boolean), a self-closing element like<Bar Baz="xxxx"/>fails deserialization withUnknownOrInvalidValue("")— the default is never applied.Root cause:
Event::Empty(self-closing XML element) was passed directly toContentDeserializer::init, which tried to parse an empty byte slice as a boolean. Thedefaultattribute fromxs:elementwas never threaded through the pipeline to the generated deserializer.Changes
ComplexMeta(models/meta/complex.rs): Adddefault: Option<String>field; include inTypeEqso types with different defaults remain distinct.pipeline/interpreter/state/generate_types/variant_processor.rs): Propagatexs:element.default→ComplexMeta.defaultwhen building inline complex types.pipeline/generator/data/complex.rs): Convert the default string to aValueRendererBox; store it inComplexDataContent.default_value. Thread adefault: Option<&str>parameter throughnew(),new_simple(), and all call sites.ComplexDataContent(models/data/complex.rs): Adddefault_value: Option<ValueRendererBox>field.pipeline/renderer/steps/defaults.rs): Emit apub fn default_content() -> T { … }associated function whendefault_valueis set.pipeline/renderer/steps/quick_xml/deserialize.rs): Inrender_deserializer_fn_next_content_simple, interceptEvent::Emptybefore callingContentDeserializer— if a default exists, calldefault_content()and return immediately.Generated output example