-
-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
There is a namespace misalignment when creating child element with .ele
and when importing fragment child using .import
.
To Reproduce
⚙️ Try to run following functions and compare their outputs.
- Function called "workingExample" outputs properly.
function workingExample() {
const doc = create({ version: '1.0' });
const root = doc.ele('ns1', 'Root');
// creates Child element with proper namespace set to "ns2"
root.ele('ns2', 'Child').txt('text');
return doc.end({ prettyPrint: true })
}
✅ Output of workingExample
function that is OK:
<?xml version="1.0"?>
<Root xmlns="ns1">
<Child xmlns="ns2">text</Child>
</Root>
- Function called "notWorkingExample" outputs child element without namespace.
function notWorkingExample() {
const doc = create({ version: '1.0' });
const root = doc.ele('ns1', 'Root');
// inserts Child element (fragment) but namespace 'ns2' is omitted
const child = fragment().ele('ns2', 'Child').txt('text');
root.import(child);
return doc.end({ prettyPrint: true })
}
notWorkingExample
function that is NOK:
<?xml version="1.0"?>
<Root xmlns="ns1">
<Child>text</Child>
</Root>
Expected behavior
Output of notWorkingExample
function is equal to output of workingExample
= both functions output:
<?xml version="1.0"?>
<Root xmlns="ns1">
<Child xmlns="ns2">text</Child>
</Root>
Version:
- node.js: [20.11.0]
- xmlbuilder2 3.1.1
afladmark, krystof-k and ad-si
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working