arelle.ModelDocument

See COPYRIGHT.md for copyright information.

Module Contents

Classes

Type

.. class:: Type

ModelDocument

.. class:: ModelDocument(modelXbrl, type, uri, filepath, xmlDocument)

ModelDocumentReference

Functions

load

Returns a new modelDocument, performing DTS discovery for instance, inline XBRL, schema, linkbase, and versioning report entry urls.

loadSchemalocatedSchema

create

Returns a new modelDocument, created from scratch, with any necessary header elements

inlineIxdsDiscover

Data

API

arelle.ModelDocument.urlMatchPattern

‘compile(…)’

arelle.ModelDocument.creationSoftwareNames

None

arelle.ModelDocument.load(modelXbrl, uri, base=None, referringElement=None, isEntry=False, isDiscovered=False, isIncluded=None, isSupplemental=False, namespace=None, reloadCache=False, **kwargs) ModelDocument | None

Returns a new modelDocument, performing DTS discovery for instance, inline XBRL, schema, linkbase, and versioning report entry urls.

Parameters:
  • uri (str or FileSource) – Identification of file to load by string filename or by a FileSource object with a selected content file.

  • referringElement (ModelObject) – Source element causing discovery or loading of this document, such as an import or xlink:href

  • isEntry (bool) – True for an entry document

  • isDiscovered (bool) – True if this document is discovered by XBRL rules, otherwise False (such as when schemaLocation and xmlns were the cause of loading the schema)

  • isIncluded (bool) – True if this document is the target of an xs:include

  • isSupplemental (True if this document is supplemental (not discovered or in DTS but adds labels or instance facts)) – True if this is processed for link relationships even if neither isEntry or isDiscovered, such as when adding additional language or documentation linkbases

  • namespace (str) – The schema namespace of this document, if known and applicable

  • reloadCache (bool) – True if desired to reload the web cache for any web-referenced files.

  • checkModifiedTime (bool :param entrypoint (in kwargs) might contain securityClassification (“unclassified”, “confidential”, “secret”, etc)) – True if desired to check modifed time of web cached entry point (ahead of usual time stamp checks).

arelle.ModelDocument.loadSchemalocatedSchema(modelXbrl, element, relativeUrl, namespace, baseUrl)
arelle.ModelDocument.create(modelXbrl, type, uri, schemaRefs=None, isEntry=False, initialXml=None, initialComment=None, base=None, discover=True, documentEncoding='utf-8', xbrliNamespacePrefix=None) ModelDocument

Returns a new modelDocument, created from scratch, with any necessary header elements

(such as the schema, instance, or RSS feed top level elements)

Parameters:
  • type (Types) – type of model document (value of ModelDocument.Types, an integer)

  • schemaRefs ([str] :param isEntry is True when creating an entry (e.g., instance)) – list of URLs when creating an empty INSTANCE, to use to discover (load) the needed DTS modelDocument objects.

class arelle.ModelDocument.Type

.. class:: Type

Static class of Enumerated type representing modelDocument type

UnknownXML

0

UnknownNonXML

1

UnknownTypes

1

firstXBRLtype

2

SCHEMA

2

LINKBASE

3

INSTANCE

4

INLINEXBRL

5

lastXBRLtype

5

DTSENTRIES

6

INLINEXBRLDOCUMENTSET

7

VERSIONINGREPORT

8

TESTCASESINDEX

9

TESTCASE

10

REGISTRY

11

REGISTRYTESTCASE

12

XPATHTESTSUITE

13

RSSFEED

14

ARCSINFOSET

15

FACTDIMSINFOSET

16

HTML

17

TESTCASETYPES

()

typeName

(‘unknown XML’, ‘unknown non-XML’, ‘schema’, ‘linkbase’, ‘instance’, ‘inline XBRL instance’, ‘entry …

static identify(filesource: arelle.FileSource.FileSource, filepath: str) int
arelle.ModelDocument.schemaBottom

None

arelle.ModelDocument.fractionParts

None

class arelle.ModelDocument.ModelDocument(modelXbrl, type, uri, filepath, xmlDocument)

.. class:: ModelDocument(modelXbrl, type, uri, filepath, xmlDocument)

The modelDocument performs discovery and initialization when loading documents. For instances, schema and linkbase references are resolved, as well as non-DTS schema locations needed to ensure PSVI-validated XML elements in the instance document (for formula processing). For DTSes, schema includes and imports are resolved, linkbase references discovered, and concepts made accessible by qname by the modelXbrl and ID at the modelDocument scope. Testcase documents (and their indexing files) are loaded as modelDocument objects.

Specialized modelDocuments are the versioning report, which must discover from and to DTSes, and an RSS feed, which has a unique XML structure.

Parameters:
  • modelXbrl (ModelXbrl) – The ModelXbrl (DTS) object owning this modelDocument.

  • uri (str) – The document’s source entry URI (such as web site URL)

  • filepath (str) – The file path of the source for the document (local file or web cache file name)

  • xmlDocument – lxml parsed xml document tree model of lxml proxy objects

Initialization

documentEncoding: str

None

xmlRootElement: Any

None

targetXbrlRootElement: arelle.ModelObject.ModelObject

None

objectId(refId='')
property qname
relativeUri(uri)
property modelDocument
property displayUri
property basename
property filepathdir
property propertyView
__repr__()
setTitle(cntlr)
setTitleInBackground()
updateFileHistoryIfNeeded()
save(overrideFilepath=None, outputZip=None, outputFile=None, updateFileHistory=True, encoding='utf-8', zipDir=None, **kwargs) None

Saves current document file.

Parameters:

overrideFilepath – specify to override saving in instance’s modelDocument.filepath

close(visited=None, urlDocs=None) None
gettype()
property creationSoftwareComment
property creationSoftware: str

Extract software product name from root level comment elements. If no comment text is found, returns string “None”. If no software product name is found, returns the comment text. If any software product names are found, returns the first.

Returns:

Extracted text.

creationSoftwareMatches(text: str | None) list[str]

Given text, extract software product names. If explicit pattern (“Software Credit: …”) is matched, only returns those matches. Otherwise, will check against a table of known software names and patterns. Interested parties can add to the table by opening a pull request, or by sending a request via email to support@arelle.org.

Parameters:

text

Returns:

List of matched software names in order found.

property processingInstructions
schemaDiscover(rootElement, isIncluded, isSupplemental, namespace)
schemaDiscoverChildElements(parentModelObject, isSupplemental=False)
baseForElement(element)
importDiscover(element)
schemalocateElementNamespace(element)
loadSchemalocatedSchemas() None
schemaLinkbaseRefsDiscover(tree)
schemaLinkbaseRefDiscover(element)
linkbasesDiscover(tree)
linkbaseDiscover(linkbaseElement, inInstance=False)
discoverHref(element, nonDTS=False, urlRewritePluginClass=None)
instanceDiscover(xbrlElement)
instanceContentsDiscover(xbrlElement)
contextDiscover(modelContext, setTargetModelXbrl=False) None
unitDiscover(unitElement, setTargetModelXbrl=False) None
inlineXbrlDiscover(htmlElement)
factDiscover(modelFact, parentModelFacts=None, parentElement=None) None
testcasesIndexDiscover(rootNode, validateTestcaseSchema)
testcaseDiscover(testcaseElement, validateTestcaseSchema)
registryDiscover(rootNode)
xPathTestSuiteDiscover(rootNode)
addDocumentReference(doc, referenceType, referringModelObject=None)
arelle.ModelDocument.inlineIxdsDiscover(modelXbrl, modelIxdsDocument, setTargetModelXbrl=False, **kwargs)
exception arelle.ModelDocument.LoadingException

Bases: Exception

class arelle.ModelDocument.ModelDocumentReference(referenceType, referringModelObject=None)

Initialization

property referringXlinkRole