-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using namespace, empty XMLNs shows up in various child node elements. #6
Comments
Yes this is by design. Child nodes do not inherit their parent namespace. If the child node in your example didn't have the const ns = "TestNameSpace";
let xmlDoc = create("UTF-8").ele(ns, "test");
xmlDoc.ele(ns, "child").txt("TestTest") ;
console.log(xmlDoc.end({ prettyPrint: true })); Let me know if that makes. Otherwise I can add a flag to let child nodes inherit their parent namespace recursively. |
Is it possible to add a flag to allow for default namespaces? For example the following would mean that all child nodes that fall under it would be for the 'xmlns="fruit"' namespace while the second blocks child nodes falls under vegetable.
and if you really wanted to get technical you can also cancel a default namespace by adding a 'cancel operation' if needed: xmlns="". |
Sure, will do. |
Just to add on, instead of using the namespace field, if I used the .att method to create the XMLNS:
It results in what I want, where the child nodes don't have an empty xmlns field. It would be nice to have a flag for namespace regardless however. |
Upon further reflection I decided to remove the |
Description: When using namespace, empty XMLNs shows up in all child node elements.
If you want to reproduce:
Create a new xml with the root element having a namespace. Once you start appending child nodes those will also have namespaces defined but will be empty, the namespaces for these should not exist.
let xmlDoc = create("UTF-8").ele("TestNameSpace", "test"); xmlDoc.ele({child: "TestTest"}) console.log(xmlDoc.end({ prettyPrint: true }));
output:
Expected Behavior: Child nodes should not have empty XMLNs defined.
Version:
Note: I could be wrong, perhaps this is intended behavior. If it is, is there something I can do so that child elements that do not need XMLNs won't have an empty field appearing in it?
The text was updated successfully, but these errors were encountered: