Add Footnote Links and Role Reference Objects to XBRL using C#

In the previous post, we learned how to add schema reference, context, unit, and fact objects to XBRL instance documents using C#. In this article, we will learn how to add footnote links and role reference objects to XBRL using C#.

The following topics shall be covered in this article:

For adding role reference and arc role reference objects to an XBRL instance document, we will be using the Aspose.Finance for .NET API. It allows creating XBRL instances, parsing, and validating the XBRL or iXBRL files. The XbrlDocument class of the API represents an XBRL document that contains one or more XBRL instances. An XBRL instance is an XML fragment, with the root element having an XBRL tag. The XbrlInstance class provides various methods and properties to work with the XBRL instance. The FootnoteLink class contains locators, resources, and arcs to describe the relationships between facts in an XBRL Instance. The API provides RoleReference class that allows referencing the definitions of any custom role attribute values used in footnote links in the XBRL instance. Similarly, the ArcRoleReference class allows resolving custom arc role values that are used in a Link base or an XBRL Instance.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.Finance

We can add a footnote link in an XBRL instance document by following the steps given below:

  1. Firstly, create an instance of the XbrlDocument class.
  2. Add a new XBRL instance to the XbrlDocument object’s instances.
  3. Add a new schema reference to the XbrlInstance object’s schema references.
  4. Get SchemaRef by its index from SchemaRefCollection.
  5. Initialize the Context instance and add it to the Context objects collection.
  6. Define a Footnote instance and set its label and text.
  7. Initialize Locator type using the Loc class instance.
  8. Define FootnoteArc with Locator label and Footnote label as arguments.
  9. Create an instance of the FootnoteLink class.
  10. Add Footnote, Locator, and FootnoteArc to relevant FootnoteLink collections.
  11. After that, add the FootnoteLink to the FootnoteLinks collection.
  12. Finally, save the XBRL file using XbrlDocument.Save() method. It takes the output file path as an argument.

The following code sample shows how to add a footnote link in an XBRL instance document using C#.

Add Role Reference Object to XBRL using C#

We can add a Role reference in an XBRL instance document by following the steps given below:

  1. Firstly, create an instance of the XbrlDocument class.
  2. Next, add a new XBRL instance to the XbrlDocument object’s instances.
  3. Then, add a new schema reference to the XbrlInstance object’s schema references.
  4. Get SchemaRef by its index from SchemaRefCollection.
  5. Next, get the RoleType from the GetRoleTypeByURI() method.
  6. Then, create an instance of the RoleReference class with the RoleType object as an argument.
  7. After that, add the RoleReference to the RoleReference objects collection.
  8. Finally, save the XBRL file using XbrlDocument.Save() method. It takes the output file path as an argument.

The following code sample shows how to add role reference in an XBRL instance document using C#.

Add Arc Role Reference Object to XBRL using C#

We can add an Arc role reference in an XBRL instance document by following the steps given below:

  1. Firstly, create an instance of the XbrlDocument class.
  2. Next, add a new XBRL instance to the XbrlDocument object’s instances.
  3. Then, add a new schema reference to the XbrlInstance object’s schema references.
  4. Next, get SchemaRef by its index from SchemaRefCollection.
  5. Then, get the ArcRoleType from the GetArcroleTypeByURI() method.
  6. Next, create an instance of the ArcRoleReference class with the ArcRoleType object as an argument.
  7. After that, add the ArcRoleReference to the ArcRoleReference objects collection.
  8. Finally, save the XBRL file using XbrlDocument.Save() method. It takes the output file path as an argument.

The following code sample shows how to add arc role reference in an XBRL instance document using C#.

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • create an XBRL document using C#;
  • add a footnote and footnote arc using footnote link to XBRL objects programmatically;
  • add role and arc role references in XBRL in C#.

Besides, you can learn more about Aspose.Finance for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also