Skip to content

Conversation

@leonelsanchesdasilva
Copy link
Collaborator

Resolves #136.

@github-actions
Copy link

github-actions bot commented Jan 23, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.4% (-0.01% 🔻)
2438/3191
🟡 Branches
65.21% (-0.16% 🔻)
1316/2018
🟡 Functions
74.09% (-0.11% 🔻)
326/440
🟡 Lines
76.78% (-0.06% 🔻)
2305/3002
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡 xpath/xpath.ts
78.51% (-2.71% 🔻)
60.37% (-4.15% 🔻)
78.57% (-1.43% 🔻)
78.76% (-3.11% 🔻)

Test suite run success

576 tests passing in 44 suites.

Report generated by 🧪jest coverage report action from 4958378

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds json-to-xml() support to the XSLT/XPath execution path (XSLT 3.0) and introduces tests/docs updates to validate and document the new capability.

Changes:

  • Implements json-to-xml() as a custom XPath function and converts its produced nodes into the library’s XNode model.
  • Adds a comprehensive new test suite for json-to-xml() behavior.
  • Updates README wording/structure and refreshes copyright headers.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/xslt/xslt.test.tsx Copyright header update.
tests/xslt/xslt-validation.test.tsx Copyright header update.
tests/xml/xmltoken.test.tsx Copyright header update.
tests/dom.test.tsx Copyright header update.
src/xslt/xslt.ts Copyright header update.
src/xpath/xpath.ts Adds json-to-xml() function support and XPathNode→XNode conversion logic; passes xsltVersion into context.
src/xpath/tokens.ts Copyright header update.
src/xpath/match-resolver.ts Copyright header update.
src/xpath/lib Updates XPath subproject commit to include needed functionality.
src/xpath/index.ts Copyright header update.
src/dom/xmltoken.ts Copyright header update.
src/dom/util.ts Copyright header update.
src/dom/functions.ts Copyright header update.
tests/json-to-xml.test.tsx New test suite covering json-to-xml() conversion scenarios and error handling.
README.md Fixes typo, adds note about XPath repo, changes unpkg URL, and relocates breaking-changes section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +315 to +320
// json-to-xml() function - XSLT 3.0 specific
functions['json-to-xml'] = (jsonText: any) => {
// Check XSLT version - only supported in 3.0
if (exprContext.xsltVersion === '1.0') {
throw new Error('json-to-xml() is not supported in XSLT 1.0. Use version="3.0" in your stylesheet.');
}
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json-to-xml() is documented/implemented as XSLT 3.0-specific, but the guard only rejects XSLT 1.0. As written, XSLT 2.0 (or other versions) would incorrectly allow the function. Update the version check to allow only XSLT 3.0 (or explicitly reject anything other than 3.0) and adjust the error message accordingly.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines +324 to +326
if (!jsonStr) {
return null;
}
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For XPath/XSLT functions that conceptually return a node-set/sequence, returning null can be ambiguous and can force downstream callers/operators to special-case it. Consider returning an empty node-set representation (e.g., []) for empty/invalid inputs to behave more like an empty sequence in XPath.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Jan 23, 2026

@leonelsanchesdasilva I've opened a new pull request, #150, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Jan 23, 2026

@leonelsanchesdasilva I've opened a new pull request, #151, to work on those changes. Once the pull request is ready, I'll request review from you.

@leonelsanchesdasilva leonelsanchesdasilva merged commit f6cbb18 into main Jan 23, 2026
3 checks passed
@leonelsanchesdasilva leonelsanchesdasilva deleted the json-to-xml branch January 23, 2026 20:43
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.

Implement json-to-xml()

2 participants