You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When MOXY marshals an org.w3c.dom.Element, it correctly includes the namespace of the element. However, any namespaces for attributes are ignored and never make it into the marshalled XML, leading to invalid XML files.
For example, let's say you have the following annotated class:
Moxy should output XML where the namespace of the attribute matches the namespace as defined programmatically in the org.w3c.dom.Element.
Note
Manually setting a prefix on the org.w3c.dom.Attr results in moxy outputting the prefix, but it's still missing the namespace.
From a little big of debugging, I found XMLFragmentReader#handlePrefixedAttribute, and while that method inspects an element's attributes, it only seems to check for xmlns and ignores everything else. That method seems to be responsible for why it works for org.w3c.dom.Element
Describe the bug
When MOXY marshals an org.w3c.dom.Element, it correctly includes the namespace of the element. However, any namespaces for attributes are ignored and never make it into the marshalled XML, leading to invalid XML files.
For example, let's say you have the following annotated class:
And you create an instance with some DOM element with a namespace attribute:
Then moxy creates the following XML
The default glassfish JAXB implementation produces correct XML:
Context: I first encountered it with generated Java files for the BPMN2 XSD schema files (which allows custom extension elements).
To Reproduce
Reproducer: https://github.com/blutorange/moxybug/tree/demo-bug-attr-ns
Simply run
mvn test
. Seems to happen with any namespaced attribute.https://github.com/blutorange/moxybug/blob/4fcfc78178f15d22d88177d008a1660ada70ea1a/src/test/java/bugdemo/Testcase.java#L26-L43
Expected behavior
Moxy should output XML where the namespace of the attribute matches the namespace as defined programmatically in the org.w3c.dom.Element.
Note
Manually setting a prefix on the org.w3c.dom.Attr results in moxy outputting the prefix, but it's still missing the namespace.
From a little big of debugging, I found
XMLFragmentReader#handlePrefixedAttribute
, and while that method inspects an element's attributes, it only seems to check forxmlns
and ignores everything else. That method seems to be responsible for why it works fororg.w3c.dom.Element
eclipselink/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/oxm/record/XMLFragmentReader.java
Lines 131 to 150 in 234c8fa
The text was updated successfully, but these errors were encountered: