Skip to content

Add optional XSD-driven schema mapping to ConvertXMLStringToJToken#35

Merged
MichalFrends1 merged 3 commits into
FSPES-117from
copilot/add-xsd-schema-support
May 7, 2026
Merged

Add optional XSD-driven schema mapping to ConvertXMLStringToJToken#35
MichalFrends1 merged 3 commits into
FSPES-117from
copilot/add-xsd-schema-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

This change adds XSD support to Frends.JSON2.ConvertXMLStringToJToken so XML conversion can use schema information when present. With XSD input, conversion now preserves intended JSON shape for schema-defined repeating/object structures instead of relying only on XML instance shape.

  • Task input contract

    • Added optional XSD parameter to Input for inline schema content used during conversion.
  • Schema-aware conversion path

    • Kept existing behavior when XSD is not provided.
    • Added XSD-enabled path that:
      • compiles and validates XML against the provided schema,
      • enriches XML with Json.NET array hints based on schema occurrence metadata,
      • serializes to JToken with preserved array/object mapping semantics.
  • Versioning and release notes

    • Bumped package version from 1.1.0 to 1.2.0 (second version number).
    • Added changelog entry describing XSD support and schema-based mapping behavior.
  • Unit coverage

    • Added test for XSD-driven mapping to verify an element declared with maxOccurs="unbounded" is emitted as a JArray even when only one element exists in the XML payload.
var input = new Input
{
    XML = "<root><person id='1'><name>Alan</name></person></root>",
    XSD = @"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
              <xs:element name='root'>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name='person' maxOccurs='unbounded'>...</xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:schema>"
};

var result = JSON.ConvertXMLStringToJToken(input);
// result.Jtoken["root"]["person"] is JArray

Copilot AI and others added 2 commits May 7, 2026 07:20
Agent-Logs-Url: https://github.com/FrendsPlatform/Frends.JSON2/sessions/73a1e239-08c8-420b-a943-a42ec2ba075d

Co-authored-by: MichalFrends1 <167774394+MichalFrends1@users.noreply.github.com>
Agent-Logs-Url: https://github.com/FrendsPlatform/Frends.JSON2/sessions/73a1e239-08c8-420b-a943-a42ec2ba075d

Co-authored-by: MichalFrends1 <167774394+MichalFrends1@users.noreply.github.com>
@MichalFrends1 MichalFrends1 changed the base branch from main to FSPES-117 May 7, 2026 18:53
@MichalFrends1 MichalFrends1 marked this pull request as ready for review May 7, 2026 18:53
@MichalFrends1 MichalFrends1 merged commit 75522da into FSPES-117 May 7, 2026
4 checks passed
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.

2 participants