def _import(self, document, element, base_location=None):
namespace = DOM.getAttr(element, '<STR_LIT>', default=None)<EOL>location = DOM.getAttr(element, '<STR_LIT:location>', default=None)<EOL>if namespace is None or location is None:<EOL><INDENT>raise WSDLError(<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>if base_location:<EOL><INDENT>location = basejoin(base_location, location)<EOL>element.setAttributeNS(None, '<STR_LIT:location>', location)<EOL><DEDENT>obimport = self.addImport(namespace, location)<EOL>obimport._loaded = <NUM_LIT:1><EOL>importdoc = DOM.loadFromURL(location)<EOL>try:<EOL><INDENT>if location.find('<STR_LIT:#>') > -<NUM_LIT:1>:<EOL><INDENT>idref = location.split('<STR_LIT:#>')[-<NUM_LIT:1>]<EOL>imported = DOM.getElementById(importdoc, idref)<EOL><DEDENT>else:<EOL><INDENT>imported = importdoc.documentElement<EOL><DEDENT>if imported is None:<EOL><INDENT>raise WSDLError(<EOL>'<STR_LIT>' % location<EOL>)<EOL><DEDENT>imported_tns = DOM.findTargetNS(imported)<EOL>if imported_tns != namespace:<EOL><INDENT>return<EOL><DEDENT>if imported.localName == '<STR_LIT>':<EOL><INDENT>imported_nodes = imported.childNodes<EOL><DEDENT>else:<EOL><INDENT>imported_nodes = [imported]<EOL><DEDENT>parent = element.parentNode<EOL>parent.removeChild(element)<EOL>for node in imported_nodes:<EOL><INDENT>if node.nodeType != node.ELEMENT_NODE:<EOL><INDENT>continue<EOL><DEDENT>child = DOM.importNode(document, node, <NUM_LIT:1>)<EOL>parent.appendChild(child)<EOL>child.setAttribute('<STR_LIT>', namespace)<EOL>attrsNS = imported._attrsNS<EOL>for attrkey in list(attrsNS.keys()):<EOL><INDENT>if attrkey[<NUM_LIT:0>] == DOM.NS_XMLNS:<EOL><INDENT>attr = attrsNS[attrkey].cloneNode(<NUM_LIT:1>)<EOL>child.setAttributeNode(attr)<EOL><DEDENT><DEDENT>if child.localName == '<STR_LIT>':<EOL><INDENT>rlocation = child.getAttributeNS(None, '<STR_LIT:location>')<EOL>alocation = basejoin(location, rlocation)<EOL>child.setAttribute('<STR_LIT:location>', alocation)<EOL><DEDENT>elif child.localName == '<STR_LIT>':<EOL><INDENT>child.setAttribute('<STR_LIT>', location)<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>importdoc.unlink()<EOL><DEDENT>return location<EOL>
Algo take <import> element's children, clone them,
        and add them to the main document.  Support for relative 
        locations is a bit complicated.  The orig document context
        is lost, so we need to store base location in DOM elements
        representing <types>, by creating a special temporary 
        "base-location" attribute,  and <import>, by resolving
        the relative "location" and storing it as "location".

        document -- document we are loading
        element -- DOM Element representing <import> 
        base_location -- location of document from which this
            <import> was gleaned.