Exemple #1
0
        public void Test_AddFootnoteResources()
        {
            xDoc = new XmlDocument();
            xDoc.AppendChild( xDoc.CreateXmlDeclaration( "1.0", "utf-16", null ) );
            XmlElement root = xDoc.CreateElement( XBRL );
            xDoc.AppendChild( root );

            root.SetAttribute(DocumentBase.XMLNS, DocumentBase.XBRL_INSTANCE_URL);
            root.SetAttribute(string.Format(DocumentBase.NAME_FORMAT, DocumentBase.XMLNS, DocumentBase.XBRL_LINKBASE_PREFIX), DocumentBase.XBRL_LINKBASE_URL);
            root.SetAttribute(string.Format(DocumentBase.NAME_FORMAT, DocumentBase.XMLNS, DocumentBase.XLINK_PREFIX), DocumentBase.XLINK_URI);

            CreateInstanceSkeleton( root, true, true );

            ArrayList mps = new ArrayList();

            // markup property
            MarkupProperty mp = new MarkupProperty();
            mp.Id = "Item-01";
            mp.address = "$c$6";
            mp.Link( new FootnoteProperty( "Footnote-01", "$c$7", "en", "this is the footnote" ) );
            mp.xmlElement = xDoc.CreateElement( "usfr_pt:element1" );
            mps.Add( mp );

            // markup property 2
            MarkupProperty mp2 = new MarkupProperty();
            mp2.Id = "Item-02";
            mp2.address = "$b$6";
            mp2.Link( new FootnoteProperty( "Footnote-02", "$c$8", "en", "this is the footnote2" ) );
            mp2.xmlElement = xDoc.CreateElement( "usfr_pt:element2" );
            mps.Add( mp2 );

            AddFootnoteLocatorsAndArcs( mps );
            AddFootnoteResources( mps );

            System.IO.StringWriter xml = new System.IO.StringWriter();
            xDoc.Save( xml );
            Console.WriteLine( xml.ToString() );

            string expectedXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
            <xbrl xmlns=""http://www.xbrl.org/2003/instance"" xmlns:link=""http://www.xbrl.org/2003/linkbase"" xmlns:xlink=""http://www.w3.org/1999/xlink"">
              <!--Context Section-->
              <!--Unit Section-->
              <!--Tuple Section-->
              <!--Element Section-->
              <!--Footnote Section-->
              <link:footnoteLink xlink:type=""extended"" xlink:role=""http://www.xbrl.org/2003/role/link"">
            <!--Document address: $c$6 - Element Name: usfr_pt:element1-->
            <link:loc xlink:type=""locator"" xlink:href=""#Item-01"" xlink:label=""Item-01_lbl"" />
            <link:footnoteArc xlink:type=""arc"" xlink:arcrole=""http://www.xbrl.org/2003/arcrole/fact-footnote"" xlink:from=""Item-01_lbl"" xlink:to=""Footnote-01"" order=""1"" />
            <!--Document address: $b$6 - Element Name: usfr_pt:element2-->
            <link:loc xlink:type=""locator"" xlink:href=""#Item-02"" xlink:label=""Item-02_lbl"" />
            <link:footnoteArc xlink:type=""arc"" xlink:arcrole=""http://www.xbrl.org/2003/arcrole/fact-footnote"" xlink:from=""Item-02_lbl"" xlink:to=""Footnote-02"" order=""1"" />
            <!--Document address: $c$7-->
            <link:footnote xlink:type=""resource"" xlink:role=""http://www.xbrl.org/2003/role/footnote"" xlink:label=""Footnote-01"" xml:lang=""en"">this is the footnote</link:footnote>
            <!--Document address: $c$8-->
            <link:footnote xlink:type=""resource"" xlink:role=""http://www.xbrl.org/2003/role/footnote"" xlink:label=""Footnote-02"" xml:lang=""en"">this is the footnote2</link:footnote>
              </link:footnoteLink>
            </xbrl>";

            if( System.Environment.OSVersion.Platform.ToString() == "128")
            {
                expectedXml = expectedXml.Replace( "\r\n", "\n");
            }
            Assert.AreEqual( expectedXml, xml.ToString() );
        }
Exemple #2
0
        /// <summary>
        /// Connects footnotes to a markup, using the markup's element id.
        /// </summary>
        private void ConnectFootnotes(MarkupProperty mp, XmlAttribute elementID,
			Dictionary<string, List<FootnoteProperty>> footnoteInfos )
        {
            string id = elementID.Value;
            List<FootnoteProperty> relatedFootnotes;
            if (footnoteInfos.TryGetValue(id, out relatedFootnotes))
            {
                if (mp.Id == null)
                    mp.Id = elementID.Value;

                //add the id to the arraylist (to check for dup IDs in FilterMarkups)
                int idx = mpIDs.BinarySearch(mp.Id);
                if (idx < 0)
                {
                    mpIDs.Insert(~idx, mp.Id);
                }

                foreach (FootnoteProperty fp in relatedFootnotes)
                {

                    //link the footnoteProperty to the markupProperty
                    mp.Link(fp);

                }

            }
        }