static public Namespace accumulateAllNamespaces(Document document) {
	Namespace res=new Namespace(document.getNamespace());
	for (Bundle b: pu.getNamedBundle(document)) {
	    Namespace ns=b.getNamespace();
	    if (ns!=null) res.extendWith(ns);
	}
	return res;
    }
static public Namespace accumulateAllNamespaces ( Document document ) { Namespace res = new Namespace ( document . getNamespace ( ) ) ; for ( Bundle b : pu . getNamedBundle ( document ) ) { Namespace ns = b . getNamespace ( ) ; if ( ns != null ) res . extendWith ( ns ) ; } return res ; }
Accumulate all namespace declarations in a single {@link Namespace} instance.
This includes the Document-level {@link Namespace} but also all Bundle-level {@link Namespace}s.

<p>This method is particular useful before serialization to XML since JAXB doesn't offer us the
means to generate prefix declaration in inner Elements. Hence, all namespaces need to be declared
at the root of the xml document.

@param document Document from which Namespaces are accumulated
@return a new instance of {@link Namespace}