I recently added support for presentation linkbase documents to the Gepsio code base. As a part of that addition, I added support for presentation linkbase documents appearing as a part of an XbrlSchema class’ LinkbaseDocuments collection. After that addition, that part of the object model looked like this:
List<PresentationLink> PresentationLinks // NEW!
In that design, an XbrlSchema object maintained a collection of LinkbaseDocument objects. Each LinkbaseDocument object, in turn, maintained four collections:
- a collection of definition links
- a collection of calculation links
- a collection of label links
- a collection of presentation links
As I looked at that design, I noticed that it didn’t quite match the way linkbase documents are actually structured in XBRL. The problem is that, in XBRL, a single linkbase document can have only one type of links. In other words, a single linkbase document can contain one of the following:
- definition links,
- OR calculation links,
- OR label links,
- OR presentation links.
This determination can be made through the value of the xlink:role attribute on a linkbase reference document, as in the following example:
In the example above, the linkbase reference is known to contain presentation linkbases because the role is http://www.xbrl.org/2003/role/presentationLinkbaseRef, which is used for presentation linkbase references. Gepsio’s linkbase document class design, however, can make it seem as though more than one linkbase type can appear in a document, since it manages four collections of all different types.
A better design would more accurately reflect the actual usage of a linkbase document. Specifically, it makes more sense to change the existing LinkbaseDocument class, which is currently a standalone class with no base or derived classes, to be a base class of derived classes that represent each of the possible linkbase document types. Each derived linkbase document type would then have a link collection specific to the containing linkbase document type. This would look something like this:
DefinitionLinkbaseDocument, derived from LinkbaseDocument
CalculationLinkbaseDocument, derived from LinkbaseDocument
LabelLinkbaseDocument, derived from LinkbaseDocument
PresentationLinkbaseDocument, derived from LinkbaseDocument
The XbrlSchema object, then would have a reference to each type of linkbase document, which would, in turn, maintain a collection of links found in the document:
Once implemented, this will be a breaking change from previous CTPs.