Skip to content

In HTML output mode, special handling for xmlns and xmlns:*.#166

Merged
leonelsanchesdasilva merged 1 commit intomainfrom
issue-165
Feb 10, 2026
Merged

In HTML output mode, special handling for xmlns and xmlns:*.#166
leonelsanchesdasilva merged 1 commit intomainfrom
issue-165

Conversation

@leonelsanchesdasilva
Copy link
Collaborator

Resolves #165

@github-actions
Copy link

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
77.76% (+0.04% 🔼)
3251/4181
🟡 Branches
67.68% (+0.14% 🔼)
1899/2806
🟡 Functions 71.06% 383/539
🟡 Lines
77.86% (+0.04% 🔼)
3113/3998

Test suite run success

610 tests passing in 60 suites.

Report generated by 🧪jest coverage report action from 42c9b3e

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

Fixes missing namespace declarations in serialized output for namespace-prefixed literal result elements, addressing issue #165.

Changes:

  • Ensure literal result elements with a namespace URI emit the appropriate xmlns / xmlns:* declaration when not already declared on an ancestor.
  • Avoid duplicating namespace declarations on nested namespace-prefixed literal result elements (via ancestor check).
  • In HTML output mode, skip serializing namespace declaration attributes (xmlns and xmlns:*), and add regression tests for issue #165.

Reviewed changes

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

File Description
tests/xslt/message-number-namespace.test.ts Adds regression tests ensuring prefixed literal result elements include the needed namespace declaration and nested cases don’t repeat it.
src/xslt/xslt.ts Adds namespace declaration injection for literal result elements when a namespace URI is present and not already in scope.
src/dom/xml-functions.ts Skips emitting xmlns attributes during HTML serialization.

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

}

// In HTML output mode, skip namespace declarations (xmlns and xmlns:*)
if (options.outputMethod === 'html' &&
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

There’s a trailing whitespace after the && on the options.outputMethod === 'html' && line; this will fail the repo’s no-trailing-spaces ESLint rule. Remove the trailing space and let formatting place the line break without extra whitespace.

Suggested change
if (options.outputMethod === 'html' &&
if (options.outputMethod === 'html' &&

Copilot uses AI. Check for mistakes.
Comment on lines +320 to +324
// In HTML output mode, skip namespace declarations (xmlns and xmlns:*)
if (options.outputMethod === 'html' &&
(attribute.nodeName === 'xmlns' || attribute.nodeName.startsWith('xmlns:'))) {
continue;
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

New behavior to omit xmlns / xmlns:* attributes during HTML serialization isn’t covered by tests. Please add a regression test that serializing a node with a namespace declaration using outputMethod: 'html' omits the declaration (and ideally that outputMethod: 'xml' still includes it).

Copilot uses AI. Check for mistakes.
@leonelsanchesdasilva leonelsanchesdasilva changed the title In HTML output mode, skipping namespace declarations (xmlns and xmlns:*) In HTML output mode, special handling for xmlns and xmlns:*. Feb 10, 2026
@leonelsanchesdasilva leonelsanchesdasilva merged commit cf3087a into main Feb 10, 2026
9 checks passed
Copy link
Contributor

Copilot AI commented Feb 10, 2026

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

@leonelsanchesdasilva leonelsanchesdasilva deleted the issue-165 branch February 10, 2026 23:50
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.

Missing output namespace declaration

2 participants