Jump to: navigation, search


Design Documentation: NamespacePrefixMapper

ER 357266


The NamespacePrefixMapper is one of these extensions - it allows the user to customize the namespaces and namespace prefixes used by a given Marshaller. By implementing the NamespacePrefixMapper interface and setting an instance on the Marshaller, the user can control how prefixes are assigned.



  • Provide an interface/abstract class the user can implement to provide custom namespaces.
  • Provide the following callback methods:
    • getPreferredPrefix - Whenever creating a prefix for a specific namespace uri, the PrefixMapper should be called to determine what prefix to use.
    • getPreDeclaredNamespaceUris - Returns a list of prefix/namespace uri mappings that should be declared at the top of this xml document.
    • getContextualNamespaceDeclarations - Returns a list of namespace declarations that will exist higher up in the document (in the case of marshalling into a SOAP message or something similar) and don't need to be re-declared.