Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

The json-to-xml() function was returning null for empty/invalid inputs, forcing downstream XPath operators to special-case null values. XPath semantics represent empty sequences as empty arrays.

Changes

  • Modified three return paths in json-to-xml() to return [] instead of null:
    • Empty/falsy input strings
    • Failed JSON-to-XML conversion
    • Failed node conversion to XNode

This aligns with existing XPath functions (e.g., key()) and eliminates the need for callers to distinguish between null and empty sequences.

// Before
if (!jsonStr) {
    return null;
}

// After  
if (!jsonStr) {
    return [];
}

💡 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.

leonelsanchesdasilva and others added 3 commits January 23, 2026 11:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: leonelsanchesdasilva <53848829+leonelsanchesdasilva@users.noreply.github.com>
Copilot AI changed the title [WIP] Update json-to-xml support in XSLT implementation Return empty arrays instead of null in json-to-xml() for XPath consistency Jan 23, 2026
@github-actions
Copy link

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 76.4% 2438/3191
🟡 Branches 65.21% 1316/2018
🟡 Functions 74.09% 326/440
🟡 Lines 76.78% 2305/3002

Test suite run success

576 tests passing in 44 suites.

Report generated by 🧪jest coverage report action from d988ac2

@leonelsanchesdasilva leonelsanchesdasilva marked this pull request as ready for review January 23, 2026 20:55
@leonelsanchesdasilva leonelsanchesdasilva merged commit b853800 into main Jan 23, 2026
3 checks passed
@leonelsanchesdasilva leonelsanchesdasilva deleted the copilot/sub-pr-147-again branch January 23, 2026 21:01
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