def createDocument(self, namespaceURI, localName, doctype=None):
prefix = self._soap_env_prefix<EOL>if namespaceURI == self.reserved_ns[prefix]:<EOL><INDENT>qualifiedName = '<STR_LIT>' %(prefix,localName)<EOL><DEDENT>elif namespaceURI is localName is None:<EOL><INDENT>self.node = self._dom.createDocument(None,None,None)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>raise KeyError('<STR_LIT>' %self.reserved_ns[prefix])<EOL><DEDENT>document = self._dom.createDocument(nsuri=namespaceURI, qname=qualifiedName, doctype=doctype)<EOL>self.node = document.childNodes[<NUM_LIT:0>]<EOL>for prefix,nsuri in list(self.reserved_ns.items()):<EOL><INDENT>self._setAttributeNS(namespaceURI=self._xmlns_nsuri, <EOL>qualifiedName='<STR_LIT>' %(self._xmlns_prefix,prefix), <EOL>value=nsuri)<EOL><DEDENT>
If specified must be a SOAP envelope, else may contruct an empty document.