'if we were created without a namespace (eg. doctype only) then
use the top level namespace for the document we\'re handling
don\'t save the namespace, as it could change from document
to document.'

def getnamespace(self, tree):

    if ((not self.namespace) and (tree.root is not None)):
        return tree.root.ns
    return self.namespace
