Пример #1
0
        /// <summary>
        /// Updates a parameter-supplied <see cref="XmlElement"/> with key information 
        /// from this <see cref="Element"/>.
        /// </summary>
        /// <param name="prefix">A prefix to be appended to this <see cref="Element"/>'s name property 
        /// to created the id attribute for <paramref name="elem"/>.</param>
        /// <param name="elem">The <see cref="XmlElement"/> to be updated.</param>
        /// <param name="doc">The <see cref="XmlDocument"/> from which new XML elements and attributes
        ///  are to be created.</param>
        /// <param name="tax">Taxonomy object for which extension is being created, can be null</param>
        public void WriteXml(string prefix, XmlElement elem, XmlDocument doc, Taxonomy tax )
        {
            // and add the attributes

            Id = string.Format(Taxonomy.ID_FORMAT, prefix, this.Name);
            elem.SetAttribute(Taxonomy.ID, Id);
            elem.SetAttribute(NAME, Name);

            elem.SetAttribute(NILLABLE, Nillable.ToString().ToLower());

            if (!tuple)
            {
                elem.SetAttribute(TYPE, OrigElementType);
            }

            elem.SetAttribute(SUBST_GROUP, SubstitutionGroup);

            if (IsAbstract)
            {
                elem.SetAttribute(ABSTRACT, "true");
            }

            if (tuple)
            {
                return;		// we're done here
            }

            bool useDefaultPath = true;
            string xbrliPrefix = Taxonomy.XBRLI_PREFIX;
            if (tax != null)
            {
                if (!tax.HasStandardXBRLIPrefix)
                {
                    useDefaultPath = false;
                    xbrliPrefix = tax.documentXBRLIPrefix;
                }

            }

            if (useDefaultPath)
            {

                XmlAttribute periodAttr = doc.CreateAttribute(Taxonomy.XBRLI_PREFIX, PER_TYPE, Taxonomy.XBRL_INSTANCE_URL);
                periodAttr.Value = PerType.ToString();
                elem.SetAttributeNode(periodAttr);

                if (ElementType == Element.MONETARY_ITEM_TYPE && BalType != Element.BalanceType.na)
                {
                    XmlAttribute balAttr = doc.CreateAttribute(Taxonomy.XBRLI_PREFIX, BALANCE, Taxonomy.XBRL_INSTANCE_URL);
                    balAttr.Value = BalType.ToString();
                    elem.SetAttributeNode(balAttr);
                }

            }
            else
            {

                XmlAttribute periodAttr = doc.CreateAttribute(xbrliPrefix, PER_TYPE, Taxonomy.XBRL_INSTANCE_URL);
                periodAttr.Value = PerType.ToString();
                elem.SetAttributeNode(periodAttr);

                if (ElementType == tax.ConvertXBRLIToValidPrefix(Element.MONETARY_ITEM_TYPE) && BalType != Element.BalanceType.na)
                {
                    XmlAttribute balAttr = doc.CreateAttribute(xbrliPrefix, BALANCE, Taxonomy.XBRL_INSTANCE_URL);
                    balAttr.Value = BalType.ToString();
                    elem.SetAttributeNode(balAttr);
                }
            }
        }