#NEWLINE# def createInstance( self , url = None ) : #NEWLINE# #INDENT# "Creates an instance document for a DTS which didn't have an instance document, such as\n        to create a new instance for a DTS which was loaded from a taxonomy or linkbase entry point.\n        \n        :param url: File name to save the new instance document\n        :type url: str\n        " #NEWLINE# from arelle import ModelDocument , FileSource #NEWLINE# if ( self . modelDocument . type == ModelDocument . Type . INSTANCE ) : #NEWLINE# #INDENT# del self . facts [ : ] #NEWLINE# self . factsInInstance . clear ( ) #NEWLINE# del self . undefinedFacts [ : ] #NEWLINE# self . contexts . clear ( ) #NEWLINE# self . units . clear ( ) #NEWLINE# self . modelDocument . idObjects . clear #NEWLINE# del self . modelDocument . hrefObjects [ : ] #NEWLINE# self . modelDocument . schemaLocationElements . clear ( ) #NEWLINE# self . modelDocument . referencedNamespaces . clear ( ) #NEWLINE# for child in list ( self . modelDocument . xmlRootElement ) : #NEWLINE# #INDENT# if ( not ( isinstance ( child , ModelObject ) and ( child . namespaceURI == XbrlConst . link ) and child . localName . endswith ( 'Ref' ) ) ) : #NEWLINE# #INDENT# self . modelDocument . xmlRootElement . remove ( child ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# priorFileSource = self . fileSource #NEWLINE# self . fileSource = FileSource . FileSource ( url , self . modelManager . cntlr ) #NEWLINE# if isHttpUrl ( self . uri ) : #NEWLINE# #INDENT# schemaRefUri = schemaRefUri . uri #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# schemaRefUri = os . path . relpath ( self . uri , os . path . dirname ( url ) ) #NEWLINE# #UNINDENT# self . modelDocument = ModelDocument . create ( self , ModelDocument . Type . INSTANCE , url , schemaRefs = [ schemaRefUri ] , isEntry = True ) #NEWLINE# if priorFileSource : #NEWLINE# #INDENT# priorFileSource . close ( ) #NEWLINE# #UNINDENT# self . closeFileSource = True #NEWLINE# del self . entryLoadingUrl #NEWLINE# #UNINDENT# from arelle import ViewWinDTS #NEWLINE# for view in self . views : #NEWLINE# #INDENT# if isinstance ( view , ViewWinDTS . ViewDTS ) : #NEWLINE# #INDENT# self . modelManager . cntlr . uiThreadQueue . put ( ( view . view , [ ] ) )