internal static Dictionary <string, bool> FilingIndicators(Xbrl.Instance instance)
        {
            var qnameFiled             = new Xml.QName("filed", FilingIndicatorsNamespace);
            var conceptFilingIndicator = instance.Dts.ResolveConcept("filingIndicator", FilingIndicatorsNamespace) as Xbrl.Taxonomy.Item;
            var filingIndicators       = new Dictionary <string, bool>();

            foreach (var fi in instance.Facts.Filter(conceptFilingIndicator, null, null))
            {
                var filedAttr = fi.Element.FindAttribute(qnameFiled);
                filingIndicators.Add(fi.Element.SchemaNormalizedValue, filedAttr == null || filedAttr.SchemaActualValue as Xsd.Boolean == true);
            }
            return(filingIndicators);
        }
Beispiel #2
0
        static void DisplayInstanceStatistics(Xbrl.Instance instance)
        {
            System.Console.WriteLine(String.Format("Instance contains {0} contexts.", instance.Contexts.Count));
            System.Console.WriteLine(String.Format("Instance contains {0} instant period contexts.", instance.Contexts.Count(c => c.PeriodAspectValue.Type == Xbrl.PeriodType.Instant)));
            System.Console.WriteLine(String.Format("Instance contains {0} start/end period contexts.", instance.Contexts.Count(c => c.PeriodAspectValue.Type == Xbrl.PeriodType.StartEnd)));
            System.Console.WriteLine(String.Format("Instance contains {0} forever period contexts.", instance.Contexts.Count(c => c.PeriodAspectValue.Type == Xbrl.PeriodType.Forever)));
            System.Console.WriteLine();

            System.Console.WriteLine(String.Format("Instance contains {0} units.", instance.Units.Count));
            System.Console.WriteLine(String.Format("Instance contains {0} simple units.", instance.Units.Count(u => u.AspectValue.IsSimple)));
            System.Console.WriteLine(String.Format("Instance contains {0} currency units.", instance.Units.Count(u => u.AspectValue.IsMonetary)));
            System.Console.WriteLine();

            System.Console.WriteLine(String.Format("Instance contains {0} facts.", instance.Facts.Count));
            System.Console.WriteLine(String.Format("Instance contains {0} nil facts.", instance.NilFacts.Count));
            System.Console.WriteLine(String.Format("Instance contains {0} top-level item facts.", instance.ChildItems.Count));
            System.Console.WriteLine(String.Format("Instance contains {0} top-level tuple facts.", instance.ChildTuples.Count));
            System.Console.WriteLine();

            var footnoteCounts = new Dictionary <string, int>();

            foreach (var footnoteLink in instance.FootnoteLinks)
            {
                foreach (var footnote in footnoteLink.Resources.OfType <Taxonomy.Footnote>())
                {
                    int count;
                    footnoteCounts.TryGetValue(footnote.XmlLang, out count);
                    footnoteCounts[footnote.XmlLang] = count + 1;
                }
            }
            if (footnoteCounts.Count > 0)
            {
                foreach (var lang in footnoteCounts)
                {
                    System.Console.WriteLine(String.Format("Instance contains {0} footnote resources in language {1}.", lang.Value, lang.Key));
                }
            }
            else
            {
                System.Console.WriteLine("Instance does not contain any footnote resources.");
            }
            System.Console.WriteLine();
        }
Beispiel #3
0
        void Init(Xbrl.Instance instance)
        {
            this.Instance = instance;

            Logger.Debug("Processing XBRL table linkbase");

            ErrorLog tableErrorLog;

            this.TableModel = this.Instance.GenerateLayoutModel(XbrlUtils.GetTableLayoutOptions(), out tableErrorLog);
            if (this.TableModel == null || tableErrorLog.HasErrors)
            {
                throw new ApplicationException(tableErrorLog.ToString());
            }

            foreach (var context in this.Instance.Contexts)
            {
                if (context.Period.IsInstant && context.DimensionAspectValues.Count == 0)
                {
                    this.ReportingContext = context;
                    break;
                }
            }
            if (this.ReportingContext == null)
            {
                foreach (var context in this.Instance.Contexts)
                {
                    if (context.DimensionAspectValues.Count == 0)
                    {
                        this.ReportingContext = context;
                        break;
                    }
                }
            }

            if (this.Instance.Units.Count > 0)
            {
                var units = new Dictionary <string, uint>();
                foreach (var unit in this.Instance.Units)
                {
                    if (unit.AspectValue.IsMonetary)
                    {
                        units.Add(unit.AspectValue.Iso4217Currency, 0);
                    }
                }
                foreach (var fact in this.Instance.Facts)
                {
                    var item = fact as Xbrl.Item;
                    if (item != null && item.UnitAspectValue != null && item.UnitAspectValue.IsMonetary)
                    {
                        units[item.UnitAspectValue.Iso4217Currency] += 1;
                    }
                }
                var mostUsedCurrency = units.OrderByDescending(x => x.Value).First();
                if (mostUsedCurrency.Value > 0)
                {
                    this.ReportingCurrency = mostUsedCurrency.Key;
                }
            }

            FilingIndicators = XbrlUtils.FilingIndicators(Instance);
        }
Beispiel #4
0
 public Report(Xbrl.Instance instance)
 {
     Init(instance);
 }