In HTML output mode, special handling for xmlns and xmlns:*.#166
In HTML output mode, special handling for xmlns and xmlns:*.#166leonelsanchesdasilva merged 1 commit intomainfrom
xmlns and xmlns:*.#166Conversation
Coverage report
Test suite run success610 tests passing in 60 suites. Report generated by 🧪jest coverage report action from 42c9b3e |
There was a problem hiding this comment.
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 (
xmlnsandxmlns:*), 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' && |
There was a problem hiding this comment.
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.
| if (options.outputMethod === 'html' && | |
| if (options.outputMethod === 'html' && |
| // In HTML output mode, skip namespace declarations (xmlns and xmlns:*) | ||
| if (options.outputMethod === 'html' && | ||
| (attribute.nodeName === 'xmlns' || attribute.nodeName.startsWith('xmlns:'))) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
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).
xmlns and xmlns:*.
|
@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. |
Resolves #165