xbrl.InstanceDocumentBuilder
¶
The xbrl.InstanceDocumentBuilder
class provides a high-level API to construct new XBRL instance documents.
-
class
xbrl.
InstanceDocumentBuilder
(DTS dts, add_generated_by_comment=True, add_xbrl_root_element=True, add_dts_references=False)¶ Creates a new
xbrl.InstanceDocumentBuilder
object for a given dts. By default, the <xbrli:xbrl> root element will be automatically inserted. To prevent this, set add_xbrl_root_element to False. It is then possible to add custom comments and PIs before the root element. Use thexbrl.InstanceDocumentBuilder.add_xbrl()
method to add the <xbrli:xbrl> root element manually.
Class methods¶
-
classmethod
xbrl.InstanceDocumentBuilder.
create_from_dts
(type cls, DTS dts, add_generated_by_comment=True, add_dts_references=True)¶
-
classmethod
xbrl.InstanceDocumentBuilder.
create_from_instance
(type cls, Instance instance, add_generated_by_comment=True, copy_comments_and_pis=True, copy_dts_references=True)¶
Methods¶
-
xbrl.InstanceDocumentBuilder.
add_arcrole_ref
(href, arcroleURI=None)¶ Adds a new <link:arcroleRef> element with the given href and arcroleURI.
-
xbrl.InstanceDocumentBuilder.
add_comment
(comment)¶ Adds a new comment information item.
-
xbrl.InstanceDocumentBuilder.
add_context
(ConstraintSet cs, id=None, force_add=False, default_occtype=None)¶ Adds a new XBRL context that corresponds to the given constraint sets. Use default_occtype to specify if dimension aspect values should be added to the segment or scenario element. By default, no duplicate is added if a context matching the aspect values in the given constraint set cs is already present. Set force_add to True to insert a new duplicate context. Returns either the id of the newly added context or the id of the matching context if it is a duplicate.
-
xbrl.InstanceDocumentBuilder.
add_enum_item_fact
(concept, value, contextRef, id=None, custom_attributes=None)¶ Adds a new enum item fact for the given concept and domain member. If value is None, @xsi:nil will be set to true.
-
xbrl.InstanceDocumentBuilder.
add_fact_footnote
(factID, footnoteFactID, arcrole=None)¶ Adds an XLink arc that connects connects two facts with the given ids. The value of the second fact represents the footnote.
-
xbrl.InstanceDocumentBuilder.
add_footnote_link
(role=None)¶ Adds a new <link:footnoteLink> element with the given role.
-
xbrl.InstanceDocumentBuilder.
add_fraction_item_fact
(concept, numerator, denominator, contextRef, unitRef, id=None, custom_attributes=None)¶ Adds a new fraction item fact for the given concept, numerator and denominator. If numerator and denominator are None, @xsi:nil will be set to true.
-
xbrl.InstanceDocumentBuilder.
add_linkbase_ref
(href, role=None)¶ Adds a new <link:linkbaseRef> element with the given href and role.
-
xbrl.InstanceDocumentBuilder.
add_namespace_binding
(namespace, prefix=None)¶ Tries to add a new namespace binding to the <xbrli:xbrl> root element. If a namespace binding for the given namespace already exists, the prefix is returned. Otherwise, a new binding with the given prefix is created. If no prefix was specified, a unique prefix will be automatically generated.
-
xbrl.InstanceDocumentBuilder.
add_non_numeric_item_fact
(concept, value, contextRef, id=None, custom_attributes=None)¶ Adds a new non-numeric item fact for the given concept and value. If value is None, @xsi:nil will be set to true.
-
xbrl.InstanceDocumentBuilder.
add_numeric_item_fact
(concept, value, contextRef, unitRef, decimals=None, precision=None, id=None, custom_attributes=None)¶ Adds a new numeric item fact for the given concept and value. If value is None, @xsi:nil will be set to true. If neither decimals or precision is specified, @decimals will be automaticaly set to INF.
-
xbrl.InstanceDocumentBuilder.
add_processing_instruction
(target, content)¶ Adds a new processing instruction information item.
-
xbrl.InstanceDocumentBuilder.
add_qname_item_fact
(concept, value, contextRef, id=None, custom_attributes=None)¶ Adds a new qname item fact for the given concept and qname. If value is None, @xsi:nil will be set to true.
-
xbrl.InstanceDocumentBuilder.
add_role_ref
(href, roleURI=None)¶ Adds a new <link:roleRef> element with the given href and roleURI.
-
xbrl.InstanceDocumentBuilder.
add_schema_ref
(href)¶ Adds a new <link:schemaRef> element with the given href.
-
xbrl.InstanceDocumentBuilder.
add_string_item_fact
(concept, value, contextRef, id=None, lang=None, custom_attributes=None)¶ Adds a new string item fact for the given concept and value. If value is None, @xsi:nil will be set to true.
-
xbrl.InstanceDocumentBuilder.
add_text_footnote
(factID, text, lang, role=None, arcrole=None)¶ Adds a new footnote resource with the given text and language together with an XLink arc that connects it to the fact with the given factID.
-
xbrl.InstanceDocumentBuilder.
add_tuple_fact
(concept, id=None, nil=False, custom_attributes=None)¶ Adds a new tuple fact for the given concept. Use nil to specify if @xsi:nil will be set to true.
-
xbrl.InstanceDocumentBuilder.
add_unit
(UnitAspectValue unit, id=None, force_add=False)¶ Adds a new XBRL unit that corresponds to the given unit aspect value. By default, no duplicate is added if a unit matching the given unit aspect value is already present. Set force_add to True to insert a new duplicate unit. Returns either the id of the newly added unit or the id of the matching unit if it is a duplicate.
-
xbrl.InstanceDocumentBuilder.
add_xbrl
(id=None, lang=None, *, Instance instance=None)¶ Adds the <xbrli:xbrl> root element. If id is specified, an @id attribute will be also generated.
-
xbrl.InstanceDocumentBuilder.
close_document
()¶ Returns an
xml.DocumentInformationItem
object represeting the generated XBRL instance document. Callingxbrl.InstanceDocumentBuilder.close_document()
automatically closes any open element tags.
-
xbrl.InstanceDocumentBuilder.
close_footnote_link
()¶ Adds the </link:footnoteLink> end tag.
-
xbrl.InstanceDocumentBuilder.
close_tuple_fact
()¶ Adds the end tag for the currently open tuple fact.
-
xbrl.InstanceDocumentBuilder.
close_xbrl
()¶ Adds the </xbrl:xbrl> end tag. Calling
xbrl.InstanceDocumentBuilder.close_document()
automatically closes any open element tags.
-
xbrl.InstanceDocumentBuilder.
copy_context
(Context context, id=None, force_add=False)¶
-
xbrl.InstanceDocumentBuilder.
copy_fact
(Fact fact, copy_ids=True)¶
-
xbrl.InstanceDocumentBuilder.
copy_facts
(FactSet facts, copy_ids=True)¶
-
xbrl.InstanceDocumentBuilder.
copy_item
(Item item, overwrite_id=False, id=None)¶
-
xbrl.InstanceDocumentBuilder.
copy_unit
(Unit unit, id=None, force_add=False)¶
-
xbrl.InstanceDocumentBuilder.
is_open
()¶ Returns True if the XBRL instance document was not finalized yet.
-
xbrl.InstanceDocumentBuilder.
set_context_id_prefix
(prefix)¶ Sets the default format for auto-generated context ids. The @id attribute will be composed of the given prefix and a unique number.
-
xbrl.InstanceDocumentBuilder.
set_unit_id_prefix
(prefix)¶ Sets the default format for auto-generated unit ids. The @id attribute will be composed of the given prefix and a unique number.
Special methods¶
__bool__, __eq__, __ge__, __gt__, __le__, __lt__, __ne__