Generating XBRL document programmatically: Use a template or a library?

5.4k views Asked by At

I am working on a financial application and one of the functionality is to generate XBRL (eXtensible Business Reporting Language) document. If you are familiar with XBRL instance documents, you might be aware that they typically refer to a large number of schemas. It is usually easier to generate these XBRL instances using (commecial) libraries.

Use case: Design a web form for the users to fill in the various fields.Generate a valid XBRL instance document using the user input.
Our platform: C# & .Net

My questions:

  • Have you used any of the (commercial) libraries? Which one would you recommend for generating 'yearly financial statements'? Altova MapForce seems to be dominant player.

  • A crude workaround to avoid using (commecial) libraries:

    • Select a valid instance document, clear all the data and store the XBRL (XML) file as a template.
    • Render the template to the user using XSLT. Collect user input and fill in the XBRL using standard XML libraries in .Net

Would you recommend this workaround? Why & why not?

Any input will be greatly appreciated :)

5

There are 5 answers

0
Luis Munoz On

To create a xbrl file I would use a template to avoid to recompile the solution if I don't have to. So far, xslt have done a good job for me.

a xslt sample to produce xbrl looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="no" />  
  <xsl:template match="/">    
    <xbrli:xbrl ....

    <xbrli:period>
     ....
<xbrli:startDate><xsl:value-of        select="yourcontext/contextstartdate"/></xbrli:endDate>
 </xbrli:period>
  </xbrli:xbrl>
  </xsl:template>
</xsl:stylesheet>

Recently i have been creating big xbrl files (500+ mb size) and using xslt still does a good job time wise. Although for consuming these files, best to build and adhoc algorithm to search and find what you look for. Using xpath make it too slow, so the best is to build a tailored algorithm to get what you need.

0
rds On

Right now, I use a variation of the second approach. I have a template, that I parse and populate with data, thanks to a standard XML library (in my case C libxml).

The idea of having a template helps to produce valid XBRL, but I think XSLT is very complex, and usually limited, I prefer to use a real programming language (python in my case, but that could be C# .net)

On the commercial tools front:

  • I have never used Altova.
  • Invoke is very good at mapping data in instances, and is really fast.

A third approach is to generate a XBRL instance only programmatically, with a XML Library. XBRL is XML, after all.

0
benPearce On

I am currently working on a project which is consuming and generating large Xbrl documents.

For generation we are currently using Altova MapForce for designing the maps and Altova FlowForce and Altova MapForce Server for executing the mapping from Xml to Xbrl. Performance of MapForce is quite good, but FlowForce is a bit clunky when working with large numbers of files.

For your use case, I would not get hung up on the data collection, MapForce can map from text files (csv) or xml. Once you have your data in a database, generate a input document (in C# as and XmlDocument) and let MapForce produce the output document in Xbrl.

0
David vun Kannon On

I would start by stepping back and reconsidering the use case. Financial reports usually contain hundreds to thousands of individual numeric facts, in addition to footnotes and longer, paragraph sized notes to the financial statements. Do you really want a user to sit in front of a web form and re-key this business critical data?

Realistically, this data exists in a database, and the safest way to get it into XBRL is a connector to that database.

As noted in the opening question, XBRL uses a large number of schemas, and the most important taxonomy schemas can contain thousands of element definitions. The UI on standard XML tools is not optimized for this situation, but mapping between the internal account identifiers and the base taxonomy tags is one of the most important use cases of the process. Again, consider storing this mapping in your financial database because it is business critical data.

1
Bill Velasquez On

On commercial libraries, Gepsio is the clear choice for .NET platform and it's Open Source.

If the user has to fill the data, your crude workaround is right. You can use XForms to allow the user to edit the blank XML directly. Most XML Databases include XForms support.

If you are not going to use an XML DB, you can use XSLTForms, an XForms plugin that runs in almost any browser.