Esempio n. 1
0
        //-------------------------------------------------------------------------------
        // Validates a footnote arc.
        //
        // Validation is handled differently, depending on the arc's role. Note that
        // the XBRL specification discusses this:
        //
        // 4.11.1.3.1 @xlink:arcrole attributes on <footnoteArc> elements
        // The value of the @xlink:arcrole attribute MUST be a URI that indicates the
        // meaning of the arc. One standard arc role value has been defined for arc role
        // values on <footnoteArc> elements. Its value is:
        //
        // http://www.xbrl.org/2003/arcrole/fact-footnote
        //
        // This arc role value is for use on a <footnoteArc> from item or tuple Locators
        // to footnote resources and it indicates that the <footnote> conveys human-readable
        // information about the fact or facts.
        //
        // For more information, see the blog post at http://gepsio.wordpress.com/2014/07/09/better-validation-coming-for-footnote-arcs-and-arc-roles/.
        //-------------------------------------------------------------------------------
        private void ValidateFootnoteArc(FootnoteArc CurrentArc)
        {
            FootnoteLocator Locator = CurrentArc.Link.GetLocator(CurrentArc.From);

            if (Locator == null)
            {
                if (CurrentArc.StandardArcRole == true)
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("CannotFindFootnoteLocator");
                    MessageBuilder.AppendFormat(StringFormat, CurrentArc.Title, CurrentArc.From);
                    validatingFragment.AddValidationError(new FootnoteArcValidationError(CurrentArc, MessageBuilder.ToString()));
                    return;
                }
                var fromFootnote = CurrentArc.Link.GetFootnote(CurrentArc.From);
                if (fromFootnote == null)
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("CannotFindFootnoteLocatorOrFootnote");
                    MessageBuilder.AppendFormat(StringFormat, CurrentArc.Title, CurrentArc.From);
                    validatingFragment.AddValidationError(new FootnoteArcValidationError(CurrentArc, MessageBuilder.ToString()));
                    return;
                }
                CurrentArc.FromFootnote = fromFootnote;
            }
            else
            {
                if ((Locator.Href.UrlSpecified == true) && (validatingFragment.UrlReferencesFragmentDocument(Locator.Href) == false))
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("FootnoteReferencesFactInExternalDoc");
                    MessageBuilder.AppendFormat(StringFormat, Locator.Href.ElementId, Locator.Href.Url);
                    validatingFragment.AddValidationError(new FootnoteArcValidationError(CurrentArc, MessageBuilder.ToString()));
                    return;
                }
                CurrentArc.FromItem = validatingFragment.GetFact(Locator.Href.ElementId);
                if (CurrentArc.FromItem == null)
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("CannotFindFactForFootnoteArc");
                    MessageBuilder.AppendFormat(StringFormat, CurrentArc.Title, Locator.Href);
                    validatingFragment.AddValidationError(new FootnoteArcValidationError(CurrentArc, MessageBuilder.ToString()));
                    return;
                }
            }
            CurrentArc.ToFootnote = CurrentArc.Link.GetFootnote(CurrentArc.To);
            if (CurrentArc.ToFootnote == null)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("CannotFindFootnoteForFootnoteArc");
                MessageBuilder.AppendFormat(StringFormat, CurrentArc.Title, CurrentArc.To);
                validatingFragment.AddValidationError(new FootnoteArcValidationError(CurrentArc, MessageBuilder.ToString()));
                return;
            }
        }