def inlineXbrlDocumentSetLoader(modelXbrl, normalizedUri, filepath, isEntry=False, namespace=None, **kwargs): if isEntry: try: if "entrypoint" in kwargs: _target = kwargs["entrypoint"]["ixdsTarget"] else: _target = modelXbrl.modelManager.formulaOptions.parameterValues.get( "ixdsTarget")[1] except (KeyError, AttributeError, IndexError, TypeError): _target = None modelXbrl.ixdsTarget = _target or None # None if an empty string specified if IXDS_SURROGATE in normalizedUri: # create surrogate entry object for inline document set which references ix documents xml = ["<instances>\n"] for i, url in enumerate(normalizedUri.split(IXDS_DOC_SEPARATOR)): if i == 0: docsetUrl = url else: xml.append("<instance>{}</instance>\n".format(url)) xml.append("</instances>\n") ixdocset = create(modelXbrl, Type.INLINEXBRLDOCUMENTSET, docsetUrl, isEntry=True, initialXml="".join(xml)) ixdocset.type = Type.INLINEXBRLDOCUMENTSET ixdocset.targetDocumentSchemaRefs = set( ) # union all the instance schemaRefs _firstdoc = True for elt in ixdocset.xmlRootElement.iter(tag="instance"): # load ix document ixdoc = load(modelXbrl, elt.text, referringElement=elt) if ixdoc is not None and ixdoc.type == Type.INLINEXBRL: # set reference to ix document in document set surrogate object referencedDocument = ModelDocumentReference( "inlineDocument", elt) ixdocset.referencesDocument[ixdoc] = referencedDocument for referencedDoc in ixdoc.referencesDocument.keys(): if referencedDoc.type == Type.SCHEMA: ixdocset.targetDocumentSchemaRefs.add( ixdoc.relativeUri(referencedDoc.uri)) ixdocset.ixNS = ixdoc.ixNS # set docset ixNS if _firstdoc: _firstdoc = False ixdocset.targetDocumentPreferredFilename = os.path.splitext( ixdoc.uri)[0] + ".xbrl" ixdoc.inDTS = True # behaves like an entry if hasattr(modelXbrl, "ixdsHtmlElements"): # has any inline root elements inlineIxdsDiscover( modelXbrl, ixdocset) # compile cross-document IXDS references return ixdocset return None
def inlineXbrlDocumentSetLoader(modelXbrl, normalizedUri, filepath, isEntry=False, namespace=None, **kwargs): if isEntry: try: if "entrypoint" in kwargs: _target = kwargs["entrypoint"]["ixdsTarget"] elif "ixdsTarget" in kwargs: # passed from validate (multio test cases) _target = kwargs["ixdsTarget"] else: _target = modelXbrl.modelManager.formulaOptions.parameterValues.get("ixdsTarget")[1] except (KeyError, AttributeError, IndexError, TypeError): _target = None modelXbrl.ixdsTarget = _target or None # None if an empty string specified if IXDS_SURROGATE in normalizedUri: # create surrogate entry object for inline document set which references ix documents xml = ["<instances>\n"] modelXbrl.ixdsDocUrls = [] schemeFixup = isHttpUrl(normalizedUri) # schemes after separator have // normalized to single / msUNCfixup = modelXbrl.modelManager.cntlr.isMSW and normalizedUri.startswith("\\\\") # path starts with double backslash \\ if schemeFixup: defectiveScheme = normalizedUri.partition("://")[0] + ":/" fixupPosition = len(defectiveScheme) for i, url in enumerate(normalizedUri.split(IXDS_DOC_SEPARATOR)): if schemeFixup and url.startswith(defectiveScheme) and url[len(defectiveScheme)] != "/": url = url[:fixupPosition] + "/" + url[fixupPosition:] if i == 0: docsetUrl = url else: if msUNCfixup and not url.startswith("\\\\") and url.startswith("\\"): url = "\\" + url xml.append("<instance>{}</instance>\n".format(url)) modelXbrl.ixdsDocUrls.append(url) xml.append("</instances>\n") ixdocset = create(modelXbrl, Type.INLINEXBRLDOCUMENTSET, docsetUrl, isEntry=True, initialXml="".join(xml)) ixdocset.type = Type.INLINEXBRLDOCUMENTSET ixdocset.targetDocumentSchemaRefs = set() # union all the instance schemaRefs _firstdoc = True for elt in ixdocset.xmlRootElement.iter(tag="instance"): # load ix document ixdoc = load(modelXbrl, elt.text, referringElement=elt) if ixdoc is not None and ixdoc.type == Type.INLINEXBRL: # set reference to ix document in document set surrogate object referencedDocument = ModelDocumentReference("inlineDocument", elt) ixdocset.referencesDocument[ixdoc] = referencedDocument for referencedDoc in ixdoc.referencesDocument.keys(): if referencedDoc.type == Type.SCHEMA: ixdocset.targetDocumentSchemaRefs.add(ixdoc.relativeUri(referencedDoc.uri)) ixdocset.ixNS = ixdoc.ixNS # set docset ixNS if _firstdoc: _firstdoc = False ixdocset.targetDocumentPreferredFilename = os.path.splitext(ixdoc.uri)[0] + ".xbrl" ixdoc.inDTS = True # behaves like an entry if hasattr(modelXbrl, "ixdsHtmlElements"): # has any inline root elements inlineIxdsDiscover(modelXbrl, ixdocset) # compile cross-document IXDS references return ixdocset return None
def inlineXbrlDocumentSetLoader(modelXbrl, normalizedUri, filepath, isEntry=False, namespace=None, **kwargs): if isEntry: try: if "entrypoint" in kwargs: _target = kwargs["entrypoint"]["ixdsTarget"] else: _target = modelXbrl.modelManager.formulaOptions.parameterValues.get("ixdsTarget")[1] except (KeyError, AttributeError, IndexError, TypeError): _target = None modelXbrl.ixdsTarget = _target or None # None if an empty string specified if IXDS_SURROGATE in normalizedUri: # create surrogate entry object for inline document set which references ix documents xml = ["<instances>\n"] for i, url in enumerate(normalizedUri.split(IXDS_DOC_SEPARATOR)): if i == 0: docsetUrl = url else: xml.append("<instance>{}</instance>\n".format(url)) xml.append("</instances>\n") ixdocset = create(modelXbrl, Type.INLINEXBRLDOCUMENTSET, docsetUrl, isEntry=True, initialXml="".join(xml)) ixdocset.type = Type.INLINEXBRLDOCUMENTSET ixdocset.targetDocumentSchemaRefs = set() # union all the instance schemaRefs _firstdoc = True for elt in ixdocset.xmlRootElement.iter(tag="instance"): # load ix document ixdoc = load(modelXbrl, elt.text, referringElement=elt) if ixdoc is not None and ixdoc.type == Type.INLINEXBRL: # set reference to ix document in document set surrogate object referencedDocument = ModelDocumentReference("inlineDocument", elt) ixdocset.referencesDocument[ixdoc] = referencedDocument for referencedDoc in ixdoc.referencesDocument.keys(): if referencedDoc.type == Type.SCHEMA: ixdocset.targetDocumentSchemaRefs.add(ixdoc.relativeUri(referencedDoc.uri)) ixdocset.ixNS = ixdoc.ixNS # set docset ixNS if _firstdoc: _firstdoc = False ixdocset.targetDocumentPreferredFilename = os.path.splitext(ixdoc.uri)[0] + ".xbrl" ixdoc.inDTS = True # behaves like an entry if hasattr(modelXbrl, "ixdsHtmlElements"): # has any inline root elements inlineIxdsDiscover(modelXbrl, ixdocset) # compile cross-document IXDS references return ixdocset return None
def xbrlDocumentSetLoader(modelXbrl, normalizedUri, filepath, isEntry=False, namespace=None, **kwargs): if INLINE_DOCUMENTSET_SURROGATE in normalizedUri: # create surrogate entry object for inline document set which references ix documents xml = ["<instances>\n"] for i, url in enumerate(normalizedUri.split("#?#")): if i == 0: docsetUrl = url else: xml.append("<instance>{}</instance>\n".format(url)) xml.append("</instances>\n") ixdocset = create(modelXbrl, Type.INLINEXBRLDOCUMENTSET, docsetUrl, isEntry=True, initialXml="".join(xml)) ixdocset.type = Type.INLINEXBRLDOCUMENTSET ixdocset.targetDocumentSchemaRefs = set( ) # union all the instance schemaRefs for elt in ixdocset.xmlRootElement.iter(tag="instance"): # load ix document ixdoc = load(modelXbrl, elt.text, referringElement=elt) # set reference to ix document in document set surrogate object referencedDocument = ModelDocumentReference("inlineDocument", elt) ixdocset.referencesDocument[ixdoc] = referencedDocument for referencedDoc in ixdoc.referencesDocument.keys(): if referencedDoc.type == Type.SCHEMA: ixdocset.targetDocumentSchemaRefs.add( ixdoc.relativeUri(referencedDoc.uri)) ixdocset.ixNS = ixdoc.ixNS # set docset ixNS inlineIxdsDiscover(modelXbrl, ixdocset) # compile cross-document IXDS references return ixdocset return None