Erstellen Sie die Datei XBRL in Python

XBRL-Instanz in C# erstellen

Aspose.Finance unterstützt das Erstellen von XBRL-Dokumenten. Dafür stellt die API die Klasse XbrlDocument bereit. Der Standardkonstruktor der XbrlDocument-Klasse kann verwendet werden, um ein neues XBRL-Instanzdokument zu erstellen.

Das folgende Code-Snippet veranschaulicht das Erstellen eines neuen XBRL-Instanzdokuments.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
xbrlDoc.save(os.path.join(outputDir, "dochavingItem.xbrl"))

Schemareferenz hinzufügen

Aspose.Finance ermöglicht Ihnen das Hinzufügen einer Schemareferenz in der neu erstellten XBRL-Instanz. Dafür stellt die API die Klasse SchemaRefCollection zur Verfügung.

Das folgende Code-Snippet zeigt das Hinzufügen einer Schemareferenz zu einer neu erstellten XBRL-Instanz.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
schemaRefs = xbrlInstance.schema_refs
schemaRefs.add(os.path.join(sourceDir, "schema.xsd"), "example", "http://example.com/xbrl/taxonomy")
xbrlDoc.save(os.path.join(outputDir, "dochavingItem.xbrl"))

Kontext hinzufügen

Aspose.Finance ermöglicht es Ihnen, Kontext in der neu erstellten XBRL-Instanz hinzuzufügen. Dafür stellt die API die Context-Klasse zur Verfügung.

Das folgende Code-Snippet veranschaulicht das Hinzufügen von Kontext in einer neu erstellten XBRL-Instanz.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
contextPeriod = ContextPeriod(datetime(2020,1,1), datetime(2020,2,10))
contextEntity = ContextEntity("exampleIdentifierScheme", "exampleIdentifier")
context = Context(contextPeriod, contextEntity)
xbrlInstance.contexts.append(context)
xbrlDoc.save(os.path.join(outputDir, "dochavingItem.xbrl"))

Einheit hinzufügen

Aspose.Finance ermöglicht es Ihnen, Kontext in der neu erstellten XBRL-Instanz hinzuzufügen. Dafür stellt die API die Klasse Unit zur Verfügung.

Das folgende Code-Snippet zeigt, wie eine Einheit in einer neu erstellten XBRL-Instanz hinzugefügt wird.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
unit = Unit(UnitType.MEASURE)
unit.measure_qualified_names.append(QualifiedName("USD", "iso4217", "http://www.xbrl.org/2003/iso4217"))
xbrlInstance.units.append(unit)
xbrlDoc.save(os.path.join(outputDir, "dochavingItem.xbrl"))

Artikel hinzufügen

Mit Aspose.Finance können Sie Elemente in der neu erstellten XBRL-Instanz hinzufügen. Dafür stellt die API die Item-Klasse zur Verfügung.

Das folgende Code-Snippet zeigt, wie Sie ein Element in einer neu erstellten XBRL-Instanz hinzufügen.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
schemaRefs = xbrlInstance.schema_refs
schemaRefs.add(os.path.join(sourceDir, "schema.xsd"), "example", "http://example.com/xbrl/taxonomy")
schema = schemaRefs[0]
contextPeriod = ContextPeriod(datetime(2020,1,1), datetime(2020,2,10))
contextEntity = ContextEntity("exampleIdentifierScheme", "exampleIdentifier")
context = Context(contextPeriod, contextEntity)
xbrlInstance.contexts.append(context)
unit = Unit(UnitType.MEASURE)
unit.measure_qualified_names.append(QualifiedName("USD", "iso4217", "http://www.xbrl.org/2003/iso4217"))
xbrlInstance.units.append(unit)
fixedAssetsConcept = schema.get_concept_by_name("fixedAssets")
if fixedAssetsConcept is not None:
item = Item(fixedAssetsConcept)
item.context_ref = context
item.unit_ref = unit
item.precision = 4
item.value = "1444"
xbrlInstance.facts.append(item)
xbrlDoc.save(os.path.join(outputDir, "dochavingItem.xbrl"))

Aspose.Finance ermöglicht es Ihnen, einen Fußnoten-Link in der neu erstellten XBRL-Instanz hinzuzufügen. Dafür stellt die API die Klasse FootnoteLink zur Verfügung.

Das folgende Code-Snippet zeigt, wie Sie einen Fußnoten-Link in einer neu erstellten XBRL-Instanz hinzufügen.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
schemaRefs = xbrlInstance.schema_refs
schemaRefs.add(os.path.join(sourceDir, "schema.xsd"), "example", "http://example.com/xbrl/taxonomy")
schema = schemaRefs[0]
contextPeriod = ContextPeriod(datetime(2020,1,1), datetime(2020,2,10))
contextEntity = ContextEntity("exampleIdentifierScheme", "exampleIdentifier")
context = Context(contextPeriod, contextEntity)
xbrlInstance.contexts.append(context)
footnoteLink = FootnoteLink()
footnote = Footnote("footnote1")
footnote.text = "Including the effects of the merger."
loc = Loc("#cd1", "fact1")
footnoteArc = FootnoteArc(loc.label, footnote.label)
footnoteLink.footnotes.append(footnote)
footnoteLink.locators.append(loc)
footnoteLink.footnote_arcs.append(footnoteArc)
xbrlInstance.footnote_links.append(footnoteLink)
xbrlDoc.save(os.path.join(outputDir, "xbrl_sample_with_footnotelink.xbrl"))

Rollenreferenz hinzufügen

Mit Aspose.Finance können Sie eine Rollenreferenz in der neu erstellten XBRL-Instanz hinzufügen. Dafür stellt die API die Klasse RoleReference bereit.

Das folgende Code-Snippet zeigt, wie Sie eine Rollenreferenz in einer neu erstellten XBRL-Instanz hinzufügen.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
schemaRefs = xbrlInstance.schema_refs
schemaRefs.add(os.path.join(sourceDir, "schema.xsd"), "example", "http://example.com/xbrl/taxonomy")
schema = schemaRefs[0]
roleType = schema.get_role_type_by_uri("http://abc.com/role/link1")
if roleType is not None:
roleReference = RoleReference(roleType)
xbrlInstance.role_references.append(roleReference)
xbrlDoc.save(os.path.join(outputDir, "xbrl_sample_with_roletype.xbrl"))

Arc-Rollenreferenz hinzufügen

Aspose.Finance ermöglicht Ihnen das Hinzufügen einer Arc-Rollenreferenz in der neu erstellten XBRL-Instanz. Dafür stellt die API die ArcroleReference-Klasse bereit.

Das folgende Code-Snippet zeigt, wie eine Arc-Rollenreferenz in einer neu erstellten XBRL-Instanz hinzugefügt wird.

xbrlDoc = XbrlDocument()
xbrlInstances = xbrlDoc.xbrl_instances
xbrlInstance = xbrlInstances[xbrlInstances.add()]
schemaRefs = xbrlInstance.schema_refs
schemaRefs.add(os.path.join(sourceDir, "schema.xsd"), "example", "http://example.com/xbrl/taxonomy")
schema = schemaRefs[0]
arcroleType = schema.get_arcrole_type_by_uri("http://abc.com/arcrole/footnote-test")
if arcroleType is not None:
arcroleReference = ArcroleReference(arcroleType)
xbrlInstance.arcrole_references.append(arcroleReference)
xbrlDoc.save(os.path.join(outputDir, "xbrl_sample_with_arcroletype.xbrl"))