question: public static void circumventBug2650 ( Document doc ) { Element documentElement = doc . getDocumentElement ( ) ; Attr xmlnsAttr = documentElement . getAttributeNodeNS ( Constants . NamespaceSpecNS , "xmlns" ) ; if ( xmlnsAttr == null ) { documentElement . setAttributeNS ( Constants . NamespaceSpecNS , "xmlns" , "" ) ; } XMLUtils . circumventBug2650internal ( doc ) ; }
target:  This method spreads all namespace attributes in a DOM document to their children. This is needed because the XML Signature XPath transform must evaluate the XPath against all nodes in the input, even against XPath namespace nodes. Through a bug in XalanJ2, the namespace nodes are not fully visible in the Xalan XPath model, so we have to do this by hand in DOM spaces so that the nodes become visible in XPath space.