In order to customize the mapping of XML prefix to URI, we currently override the following classes:
Which class is used depends on the environment (standard JDK or Glassfish). However those classes are not public API; they may not be present in other implementations, and their API sometime change.
It seems that javax.xml.namespace.NamespaceContext in public API can do the job. We need to specify an instance to javax.xml.stream.XMLStreamWriter using the setNamespaceContext method, then to use the javax.xml.bind.Marshaller method that expect a XMLStreamWriter argument.