arelle.ModelXbrl

See COPYRIGHT.md for copyright information.

Module Contents

Classes

ModelXbrl

.. class:: ModelXbrl(modelManager)

Functions

load

Each loaded instance, DTS, testcase, testsuite, versioning report, or RSS feed, is represented by an instance of a ModelXbrl object. The ModelXbrl object has a collection of ModelDocument objects, each representing an XML document (for now, with SQL whenever its time comes). One of the modelDocuments of the ModelXbrl is the entry point (of discovery or of the test suite).

create

loadSchemalocatedSchemas

Data

API

arelle.ModelXbrl.profileStatNumber

0

arelle.ModelXbrl.AUTO_LOCATE_ELEMENT

‘771407c0-1d0c-11e1-be5e-028037ec0200’

arelle.ModelXbrl.DEFAULT

‘intern(…)’

arelle.ModelXbrl.NONDEFAULT

‘intern(…)’

arelle.ModelXbrl.DEFAULTorNONDEFAULT

‘intern(…)’

arelle.ModelXbrl.EMPTY_TUPLE: arelle.typing.EmptyTuple

()

arelle.ModelXbrl._NOT_FOUND

‘object(…)’

arelle.ModelXbrl.load(modelManager: arelle.ModelManager.ModelManager, url: str | arelle.FileSource.FileSource, nextaction: str | None = None, base: str | None = None, useFileSource: arelle.FileSource.FileSource | None = None, errorCaptureLevel: str | None = None, **kwargs: str) ModelXbrl

Each loaded instance, DTS, testcase, testsuite, versioning report, or RSS feed, is represented by an instance of a ModelXbrl object. The ModelXbrl object has a collection of ModelDocument objects, each representing an XML document (for now, with SQL whenever its time comes). One of the modelDocuments of the ModelXbrl is the entry point (of discovery or of the test suite).

Parameters:
  • url – may be a filename or FileSource object

  • nextaction – text to use as status line prompt on conclusion of loading and discovery

  • base – the base URL if any (such as a versioning report’s URL when loading to/from DTS modelXbrl).

  • useFileSource – for internal use (when an entry point is in a FileSource archive and discovered files expected to also be in the entry point’s archive.

arelle.ModelXbrl.create(modelManager: arelle.ModelManager.ModelManager, newDocumentType: int | None = None, url: str | None = None, schemaRefs: str | None = None, createModelDocument: bool = True, isEntry: bool = False, errorCaptureLevel: str | None = None, initialXml: str | None = None, initialComment: str | None = None, base: str | None = None, discover: bool = True, xbrliNamespacePrefix: str | None = None) ModelXbrl
arelle.ModelXbrl.loadSchemalocatedSchemas(modelXbrl: ModelXbrl) None
arelle.ModelXbrl.MatchSubstitutionGroupValueType

‘TypeVar(…)’

class arelle.ModelXbrl.ModelXbrl(modelManager: arelle.ModelManager.ModelManager, errorCaptureLevel: str | None = None)

.. class:: ModelXbrl(modelManager)

ModelXbrl objects represent loaded instances and inline XBRL instances and their DTSes, DTSes (without instances), versioning reports, testcase indexes, testcase variation documents, and other document-centric loadable objects.

Parameters:

modelManager – The controller’s modelManager object for the current session or command line process.

Initialization

closeFileSource: bool

None

dimensionDefaultConcepts: dict[arelle.ModelDtsObject.ModelConcept, arelle.ModelDtsObject.ModelConcept]

None

entryLoadingUrl: str

None

fileSource: arelle.FileSource.FileSource

None

ixdsDocUrls: list[str]

None

ixdsHtmlElements: list[str]

None

isDimensionsValidated: bool

None

locale: arelle.typing.LocaleDict | None

None

modelDocument: arelle.ModelDocument.ModelDocument | None

None

uri: str

None

uriDir: str

None

targetRelationships: set[arelle.ModelObject.ModelObject]

None

qnameDimensionContextElement: dict[arelle.ModelValue.QName, str]

None

_factsByDimQname: dict[arelle.ModelValue.QName, dict[arelle.ModelValue.QName | str | None, set[arelle.ModelInstanceObject.ModelFact]]]

None

_factsByQname: dict[arelle.ModelValue.QName, set[arelle.ModelInstanceObject.ModelFact]]

None

_factsByDatatype: dict[bool | tuple[bool, arelle.ModelValue.QName], set[arelle.ModelInstanceObject.ModelFact]]

None

_factsByLocalName: dict[str, set[arelle.ModelInstanceObject.ModelFact]]

None

_factsByPeriodType: dict[str, set[arelle.ModelInstanceObject.ModelFact]]

None

_nonNilFactsInInstance: set[arelle.ModelInstanceObject.ModelFact]

None

_startedProfiledActivity: float

None

_startedTimeStat: float

None

init(keepViews: bool = False, errorCaptureLevel: str | None = None) None
close() None

Closes any views, formula output instances, modelDocument(s), and dereferences all memory used

property isClosed: bool
Returns:

bool – True if closed (python object has deferenced and deleted all attributes after closing)

reload(nextaction: str, reloadCache: bool = False) None

Reloads all model objects from their original entry point URL, preserving any open views (which are reloaded).

Parameters:
  • nextAction – status line text string, if any, to show upon completion

  • reloadCache – True to force clearing and reloading of web cache, if working online.

closeViews() None

Close views associated with this modelXbrl

property displayUri: Any
relationshipSet(arcrole: str, linkrole: tuple[str, ...] | str | None = None, linkqname: arelle.ModelValue.QName | None = None, arcqname: arelle.ModelValue.QName | None = None, includeProhibits: bool = False) arelle.ModelRelationshipSet.ModelRelationshipSet

Returns a relationship set matching specified parameters (only arcrole is required).

Resolve and determine relationship set. If a relationship set of the same parameters was previously resolved, it is returned from a cache.

Parameters:
  • arcrole – Required arcrole, or special collective arcroles ‘XBRL-dimensions’, ‘XBRL-formula’, and ‘Table-rendering’

  • linkrole – Linkrole (wild if None)

  • arcqname – Arc element qname (wild if None)

  • includeProhibits – True to include prohibiting arc elements as relationships

roleUriTitle(roleURI: str) str
roleTypeDefinition(roleURI: str, lang: str | None = None) str
roleTypeName(roleURI: str, lang: str | None = None) str
matchSubstitutionGroup(elementQname: arelle.ModelValue.QName, subsGrpMatchTable: dict[arelle.ModelValue.QName | None, arelle.ModelXbrl.MatchSubstitutionGroupValueType]) arelle.ModelXbrl.MatchSubstitutionGroupValueType | None

Resolve a subsitutionGroup for the elementQname from the match table

Used by ModelObjectFactory to return Class type for new ModelObject subclass creation, and isInSubstitutionGroup

Parameters:
  • elementQname – Element/Concept QName to find substitution group

  • subsGrpMatchTable – Table of substitutions used to determine xml proxy object class for xml elements and substitution group membership

isInSubstitutionGroup(elementQname: arelle.ModelValue.QName, subsGrpQnames: arelle.ModelValue.QName | collections.abc.Iterable[arelle.ModelValue.QName] | None) bool

Determine if element is in substitution group(s) Used by ModelObjectFactory to return Class type for new ModelObject subclass creation, and isInSubstitutionGroup

Parameters:
  • elementQname – Element/Concept QName to determine if in substitution group(s)

  • subsGrpQnames – QName or iterable of QNames

createInstance(url: str) None

Creates an instance document for a DTS which didn’t have an instance document, such as to create a new instance for a DTS which was loaded from a taxonomy or linkbase entry point.

Parameters:

url – File name to save the new instance document

saveInstance(**kwargs: Any) Any

Saves current instance document file.

Parameters:

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

property prefixedNamespaces: dict[str, str]

Dict of prefixes for namespaces defined in DTS

matchContext(entityIdentScheme: str, entityIdentValue: str, periodType: str, periodStart: datetime.date | datetime.datetime, periodEndInstant: datetime.date | datetime.datetime, dims: dict[arelle.ModelInstanceObject.ModelDimensionValue, arelle.ModelValue.QName], segOCCs: arelle.ModelObject.ModelObject, scenOCCs: arelle.ModelObject.ModelObject) arelle.ModelInstanceObject.ModelContext | None

Finds matching context, by aspects, as in formula usage, if any

Parameters:
  • entityIdentScheme – Scheme to match

  • entityIdentValue – Entity identifier value to match

  • periodType – Period type to match (“instant”, “duration”, or “forever”)

  • periodStart – Date or dateTime of period start

  • periodEndInstant – Date or dateTime of period send

  • dims – Dimensions

  • segOCCs – Segment non-dimensional nodes

  • scenOCCs – Scenario non-dimensional nodes

createContext(entityIdentScheme: str, entityIdentValue: str, periodType: str, periodStart: datetime.datetime | datetime.date, periodEndInstant: datetime.datetime | datetime.date, priItem: arelle.ModelValue.QName | None, dims: dict[int | arelle.ModelValue.QName, arelle.ModelValue.QName | arelle.PrototypeInstanceObject.DimValuePrototype], segOCCs: arelle.ModelObject.ModelObject, scenOCCs: arelle.ModelObject.ModelObject, afterSibling: arelle.ModelObject.ModelObject | str | None = None, beforeSibling: arelle.ModelObject.ModelObject | None = None, id: str | None = None) arelle.ModelObject.ModelObject

Creates a new ModelContext and validates (integrates into modelDocument object model).

Parameters:
  • entityIdentScheme – Scheme to match

  • entityIdentValue – Entity identifier value to match

  • periodType – Period type to match (“instant”, “duration”, or “forever”)

  • periodStart – Date or dateTime of period start

  • periodEndInstant – Date or dateTime of period send

  • dims – Dimensions

  • segOCCs – Segment non-dimensional nodes

  • scenOCCs – Scenario non-dimensional nodes

  • beforeSibling – lxml element in instance to insert new concept before

  • afterSibling – lxml element in instance to insert new concept after

  • id – id to assign to new context, if absent an id will be generated

matchUnit(multiplyBy: list[arelle.ModelValue.QName], divideBy: list[arelle.ModelValue.QName]) arelle.ModelInstanceObject.ModelUnit | None

Finds matching unit, by measures, as in formula usage, if any

Parameters:
  • multiplyBy – List of multiply-by measure QNames (or top level measures if no divideBy)

  • divideBy – List of multiply-by measure QNames (or empty list if no divideBy)

createUnit(multiplyBy: list[arelle.ModelValue.QName], divideBy: list[arelle.ModelValue.QName], afterSibling: arelle.ModelObject.ModelObject | None = None, beforeSibling: arelle.ModelObject.ModelObject | None = None, id: str | None = None) arelle.ModelObject.ModelObject

Creates new unit, by measures, as in formula usage, if any

Parameters:
  • multiplyBy – List of multiply-by measure QNames (or top level measures if no divideBy)

  • divideBy – List of multiply-by measure QNames (or empty list if no divideBy)

  • beforeSibling – lxml element in instance to insert new concept before

  • afterSibling – lxml element in instance to insert new concept after

  • id – id to assign to new unit, if absent an id will be generated

property nonNilFactsInInstance: set[arelle.ModelInstanceObject.ModelFact]

Facts in the instance which are not nil, cached

property factsByQname: dict[arelle.ModelValue.QName, set[arelle.ModelInstanceObject.ModelFact]]

Facts in the instance indexed by their QName, cached

property factsByLocalName: dict[str, set[arelle.ModelInstanceObject.ModelFact]]

Facts in the instance indexed by their LocalName, cached

factsByDatatype(notStrict: bool, typeQname: arelle.ModelValue.QName) set[arelle.ModelInstanceObject.ModelFact] | None

Facts in the instance indexed by data type QName, cached as types are requested

Parameters:

notSctrict – if True, fact may be derived

factsByPeriodType(periodType: str) set[arelle.ModelInstanceObject.ModelFact]

Facts in the instance indexed by periodType, cached

Parameters:

periodType – Period type to match (“instant”, “duration”, or “forever”)

factsByDimMemQname(dimQname: arelle.ModelValue.QName, memQname: arelle.ModelValue.QName | str | None = None) set[arelle.ModelInstanceObject.ModelFact]

Facts in the instance indexed by their Dimension and Member QName, cached If Member is None, returns facts that have the dimension (explicit or typed) If Member is NONDEFAULT, returns facts that have the dimension (explicit non-default or typed) If Member is DEFAULT, returns facts that have the dimension (explicit non-default or typed) defaulted

property contextsInUse: Any
property dimensionsInUse: set[Any]
matchFact(otherFact: arelle.ModelInstanceObject.ModelFact, unmatchedFactsStack: list[arelle.ModelInstanceObject.ModelFact] | None = None, deemP0inf: bool = False, matchId: bool = False, matchLang: bool = True) arelle.ModelInstanceObject.ModelFact | None

Finds matching fact, by XBRL 2.1 duplicate definition (if tuple), or by QName and VEquality (if an item), lang and accuracy equality, as in formula and test case usage

Parameters:

otherFact – Fact to match

DeemP0inf:

boolean for formula validation to deem P0 facts to be VEqual as if they were P=INF

createFact(conceptQname: arelle.ModelValue.QName, attributes: tuple[str, str] | tuple[tuple[str, str]] | None = None, text: str | None = None, parent: arelle.ModelObject.ModelObject | None = None, afterSibling: arelle.ModelObject.ModelObject | None = None, beforeSibling: arelle.ModelObject.ModelObject | None = None, validate: bool = True) arelle.ModelInstanceObject.ModelFact | arelle.ModelObject.ModelObject

Creates new fact, as in formula output instance creation, and validates into object model

Parameters:
  • conceptQname – QNames of concept

  • attributes – Tuple of name, value, or tuples of name, value tuples (name,value) or ((name,value)[,(name,value…)]), where name is either QName or clark-notation name string

  • text – Text content of fact (will be converted to xpath compatible str by FunctionXS.xsString)

  • parent – lxml element in instance to append as child of

  • beforeSibling – lxml element in instance to insert new concept before

  • afterSibling – lxml element in instance to insert new concept after

  • validate – specify False to block XML Validation (required when constructing a tuple which is invalid until after it’s contents are created)

setIsModified() None

Records that the underlying document has been modified.

isModified() bool

Check if the underlying document has been modified.

modelObject(objectId: str | int) arelle.ModelObject.ModelObject | None

Finds a model object by an ordinal ID which may be buried in a tkinter view id string (e.g., ‘somedesignation_ordinalnumber’).

Parameters:

objectId – string which includes _ordinalNumber, produced by ModelObject.objectId(), or integer object index

viewModelObject(objectId: str | int) None

Finds model object, if any, and synchronizes any views displaying it to bring the model object into scrollable view region and highlight it

Parameters:

objectId – string which includes _ordinalNumber, produced by ModelObject.objectId(), or integer object index

effectiveMessageCode(messageCodes: tuple[Any] | str) str | None

If codes includes EFM, GFM, HMRC, or SBR-coded error then the code chosen (if a sequence) corresponds to whether EFM, GFM, HMRC, or SBR validation is in effect.

isLoggingEffectiveFor(**kwargs: Any) bool
logArguments(messageCode: str, msg: str, codedArgs: dict[str, str]) Any
loggableValue(argValue: Any) str | dict[Any, Any]
debug(codes: str | tuple[str, ...], msg: str, **args: Any) None

Same as error(), but as info

info(codes: str | tuple[str, ...], msg: str, **args: Any) None

Same as error(), but as info

warning(codes: str | tuple[str, ...], msg: str, **args: Any) None

Same as error(), but as warning, and no error code saved for Validate

log(level: str, codes: Any, msg: str, **args: Any) None

Same as error(), but level passed in as argument

error(codes: str | tuple[str, ...], msg: str, **args: Any) None

Logs a message as info, by code, logging-system message text (using %(name)s named arguments to compose string by locale language), resolving model object references (such as qname), to prevent non-dereferencable memory usage. Supports logging system parameters, and special parameters modelObject, modelXbrl, or modelDocument, to provide trace information to the file, source line, and href (XPath element scheme pointer). Supports the logging exc_info argument.

Args may include a specification of one or more ModelObjects that identify the source of the message, as modelObject={single-modelObject, (sequence-of-modelObjects)} or modelXbrl=modelXbrl or modelDocument=modelDocument.

Args must include a named argument for each msg %(namedArg)s replacement.

Parameters:
  • codes – Message code or tuple/list of message codes

  • msg – Message text string to be formatted and replaced with named parameters in **args

  • **args – Named arguments including modelObject, modelXbrl, or modelDocument, named arguments in msg string, and any exc_info argument.

  • messageCodes – If first parameter codes, above, is dynamically formatted, this is a documentation string of the message codes only used for extraction of the message catalog document (not used in run-time processing).

exception(codes: str | tuple[str, ...], msg: str, **args: str) None

Same as error(), but as exception

logProfileStats() None

Logs profile stats that were collected

profileStat(name: str | None = None, stat: float | None = None) None

order 1xx - load, import, setup, etc order 2xx - views, 26x - table lb 3xx diff, other utilities 5xx validation 6xx formula

profileActivity(activityCompleted: str | None = None, minTimeToShow: float = 0) None

Used to provide interactive GUI messages of long-running processes.

When the time between last profileActivity and this profileActivity exceeds minTimeToShow, then the time is logged (if it is shorter than it is not logged), thus providing feedback of long running (and possibly troublesome) processing steps.

Parameters:
  • activityCompleted – Description of activity completed, or None if call is just to demark starting of a profiled activity.

  • minTimeToShow – Seconds of elapsed time for activity, if longer then the profile message appears in the log.

saveDTSpackage() None

Contributed program to save DTS package as a zip file. Refactored into a plug-in (and may be removed from main code).