Skip to content

Fix recursive xsl:call-template producing NaN via result-tree fragment variables - #218

Merged
leonelsanchesdasilva merged 1 commit into
mainfrom
fix/issue-217-call-template-recursion
Aug 10, 2026
Merged

Fix recursive xsl:call-template producing NaN via result-tree fragment variables#218
leonelsanchesdasilva merged 1 commit into
mainfrom
fix/issue-217-call-template-recursion

Conversation

@leonelsanchesdasilva

Copy link
Copy Markdown
Collaborator

xsl:variable/xsl:param with element content builds a NodeSetValue wrapping a DocumentFragment (nodeType 11). Arithmetic expressions atomizing such a value fell through getStringValueFromNode() to null, coercing to NaN. This blocked recursive named-template patterns (factorial, power, etc.) that stash a nested call-template's result in a variable before using it in arithmetic.

Bumps src/xpath/lib submodule to DesignLiquido/xpath@3dff86f, which fixes getStringValueFromNode() to treat document fragment nodes like elements.

Resolves #217

…t variables

xsl:variable/xsl:param with element content builds a NodeSetValue wrapping
a DocumentFragment (nodeType 11). Arithmetic expressions atomizing such a
value fell through getStringValueFromNode() to null, coercing to NaN. This
blocked recursive named-template patterns (factorial, power, etc.) that
stash a nested call-template's result in a variable before using it in
arithmetic.

Bumps src/xpath/lib submodule to DesignLiquido/xpath@3dff86f, which fixes
getStringValueFromNode() to treat document fragment nodes like elements.

Resolves #217

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 79.31% 3427/4321
🟡 Branches 69.08% 2013/2914
🟡 Functions 72.56% 402/554
🟡 Lines 79.46% 3281/4129

Test suite run success

675 tests passing in 66 suites.

Report generated by 🧪jest coverage report action from 89664d2

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes an XPath/XSLT interoperability bug where result-tree fragment variables (document fragments, nodeType === 11) could atomize to null and then coerce to NaN during arithmetic, breaking common recursive xsl:call-template patterns (e.g., factorial) that store a nested call result in an xsl:variable.

Changes:

  • Adds a regression test covering recursive xsl:call-template with an intermediate variable used in arithmetic (Issue #217).
  • (Per PR description) Bumps the src/xpath/lib submodule to include the upstream fix that treats document fragments as element-like for string-value extraction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@leonelsanchesdasilva
leonelsanchesdasilva merged commit 03237fe into main Aug 10, 2026
4 checks passed
@leonelsanchesdasilva
leonelsanchesdasilva deleted the fix/issue-217-call-template-recursion branch August 10, 2026 19:13
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.

Recursion not possible with call-template

2 participants