Include namespace declarations on root elemant at serialization time #314
Unanswered
patricklucas
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
The way to do this (for serialization) would be the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am aware I can use the
@XmlNamespaceDeclSpecsannotation to include namespace declarations on an element, but is there a way to tack those on at serialization time rather than using an annotation?My use-case is that part of the element structure is described as
xs:any, and I'm successfully usingCompactFragmentto handle this content, and I would like consumers of the library containing the serializable classes to be able to add namespace declarations to the root element when serializing so that the declaration doesn't have to be included on every singleCompactFragmentinstance that uses that namespace.In my case, a document can have thousands of such inner elements, and it would be nice to have the namespace declared just once. The library itself is not aware of what namespaces a consumer might want to use, so it cannot preemptively include them using
@XmlNamespaceDeclSpecs.I traced the code just a bit, and found that ultimately the decls are exposed in the descriptor via a call to
config.policy.elementNamespaceDecls, so perhaps there is a way (or could be a way) to provide additional namespace declarations on the serializer config?Beta Was this translation helpful? Give feedback.
All reactions