Friday, September 30, 2011

Facts, Items and Tuples

The current CTP of Gepsio (which, as of this writing, is the Feb 2011 CTP) exposes a collection of Fact objects as a property in an XbrlFragment. With this arrangement, you can write code like this:

var MyXbrlDocument = new XbrlDocument();
MyXbrlDocument.Load("xbrldata.xml");
foreach(var CurrentFragment in MyXbrlDocument.XbrlFragments)
{
foreach(var CurrentFact in CurrentFragment.Facts)
{
// Ooh! An XBRL fact!
}
}



I have been working on adding support for tuples in the next CTP, and, in doing so, have come to realize that this scenario is incomplete.


The Fact class in the current CTP is a standalone class. It doesn’t inherit from any other class, nor is it a base class for a derived class. The issue with the current CTP is that the only facts that it reads and exposes are single-value facts. Any tuples in the XBRL document are ignored and not included as a Fact instance.


In actuality, the XBRL specification supports two types of facts:



  • single-value facts, called items

  • multiple-value facts, called tuples

The next CTP will provide support for tuples, and, as such, Gepsio’s understanding of a fact will be more complete. In the next CTP, the Fact class will remain, but it will serve as a base class for a new class called Item and another new class called Tuple:

public class Fact
{
// magic happens here
}

public class Item : Fact
{
// more magic happens here
}

public class Tuple : Fact
{
// even more magic happens here
}



Fact collections will remain in place, but Fact items can be examined to determine whether they are, in fact, items or tuples. This updated design will allow Gepsio to detect tuples in loaded XBRL documents and perform the appropriate work needed to expose tuples to Gepsio clients.

No comments:

Post a Comment