Working with XBRL Fragments - JeffFerguson/gepsio GitHub Wiki

Gepsio arranges XBRL instance data loaded into an XbrlDocument instance into fragments. Each fragment is an object of class JeffFerguson.Gepsio.XbrlFragment, and the XbrlDocument class manages a property called XbrlFragments, which is a list of XbrlFragment objects. XBRL data is found in an XBRL fragment.

An XBRL fragment is a fragment of XBRL data having an <xbrl> tag as its root. In the generic case, an XBRL document will have an <xbrl> tag as the root tag of the XML document, and, in this case, the entire XBRL document is one large XBRL fragment. However, section 4.1 of the XBRL 2.1 Specification makes provisions for multiple XBRL fragments to be stored in a single document:

"If multiple 'data islands' of XBRL mark-up are included in a larger document, the xbrl element is the container for each [fragment]."

The following example illustrates working with XBRL fragments:

using JeffFerguson.Gepsio;
using System;

namespace Fragments
{
    class Program
    {
        static void Main(string[] args)
        {
            var xbrlDoc = new XbrlDocument();
            xbrlDoc.Load(@"..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\301-01-IdScopeValid.xml");

            Console.WriteLine($"Number of fragments in the loaded document: {xbrlDoc.XbrlFragments.Count}.");
            foreach(var currentFragment in xbrlDoc.XbrlFragments)
            {
                // Work with the fragment here.
            }
        }
    }
}

In almost all cases, a loaded XBRL instance will have one fragment, but well-written code should consider the possibility of multiple fragments, since the concept is supported in the specification.

⚠️ **GitHub.com Fallback** ⚠️