Skip to content

Generate XSI namespace constants for nillable type support#230

Closed
Copilot wants to merge 6 commits intomasterfrom
copilot/add-tests-xsi-namespace
Closed

Generate XSI namespace constants for nillable type support#230
Copilot wants to merge 6 commits intomasterfrom
copilot/add-tests-xsi-namespace

Conversation

Copy link

Copilot AI commented Feb 5, 2026

Generated code referenced undefined PREFIX_XSI and NS_XSI constants when combining Global namespace serialization with nillable types, causing compilation errors.

Changes

Constant Generation

  • Modified namespace_const.rs and prefix_const.rs to emit NS_XSI and PREFIX_XSI when NILLABLE_TYPE_SUPPORT is enabled
  • Constants now generate even for schemas without explicit namespace definitions

Path Resolution

  • Updated serialize.rs to use PathData and resolve_type_for_serialize_module() for XSI constants
  • Ensures correct module path depth (super::, super::super::, etc.) matching other namespace constants

Test Coverage

  • Added nillable_global_namespace test suite validating the fix
  • Updated expectations for existing tests using nillable types

Example

Before this fix, generated code would fail to compile:

// Generated code (broken)
helper.write_xmlns(&mut bytes, Some(&super::PREFIX_XSI), &super::NS_XSI);
// error: cannot find value `PREFIX_XSI` in module `super`

Now generates:

// At module root
pub const PREFIX_XSI: NamespacePrefix = NamespacePrefix::new_const(b"xsi");
pub const NS_XSI: Namespace = Namespace::new_const(b"http://www.w3.org/2001/XMLSchema-instance");

// In serialization code (nested module)
helper.write_xmlns(&mut bytes, Some(&super::super::PREFIX_XSI), &super::super::NS_XSI);
Original prompt

This section details on the original issue you should resolve

<issue_title>Add tests to verify XSI namespace is working correctly</issue_title>
<issue_description>Two issues needs to be verified:

  1. When explicitly adding the XSI schema to the parser, a error is raised:
    config.parser.schemas = vec![
        // Build started to fail after i added any of them.
        Schema::Url(url::Url::parse(http://www.w3.org/2001/XMLSchema-instance).unwrap()),
        Schema::File("xsd/xsi-instance.xsd".into()),
    ];
    config.parser.resolver = vec![Resolver::Web, Resolver::File];
  1. The XSI_PREFIX constant is not defined and cause compiler errors in the generated code:
RenderStep::QuickXmlSerialize {
    namespaces: NamespaceSerialization::Global,
    default_namespace: None,
}

helper.write_xmlns(
    &mut bytes,
    Some(&super::PREFIX_XSI),
    &super::NS_XSI,
);
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits February 5, 2026 19:48
Co-authored-by: Bergmann89 <2215174+Bergmann89@users.noreply.github.com>
Co-authored-by: Bergmann89 <2215174+Bergmann89@users.noreply.github.com>
Co-authored-by: Bergmann89 <2215174+Bergmann89@users.noreply.github.com>
Co-authored-by: Bergmann89 <2215174+Bergmann89@users.noreply.github.com>
Co-authored-by: Bergmann89 <2215174+Bergmann89@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests to verify XSI namespace functionality Generate XSI namespace constants for nillable type support Feb 5, 2026
Copilot AI requested a review from Bergmann89 February 5, 2026 20:22
@Bergmann89
Copy link
Owner

Will be addressed in #233. Closed.

@Bergmann89 Bergmann89 closed this Feb 6, 2026
@Bergmann89 Bergmann89 deleted the copilot/add-tests-xsi-namespace branch February 6, 2026 23:18
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 this pull request may close these issues.

Add tests to verify XSI namespace is working correctly

2 participants