예제 #1
0
 private void ValidateScenarioNode(INode ScenarioNode)
 {
     if (ScenarioNode.NamespaceURI.Equals(XbrlDocument.XbrlNamespaceUri) == true)
     {
         string        MessageFormat  = AssemblyResources.GetName("ScenarioNodeUsingXBRLNamespace");
         StringBuilder MessageBuilder = new StringBuilder();
         MessageBuilder.AppendFormat(MessageFormat, this.Id, ScenarioNode.Name);
         this.Fragment.AddValidationError(new ContextValidationError(this, MessageBuilder.ToString()));
     }
     if (ScenarioNode.Prefix.Length > 0)
     {
         XbrlSchema NodeSchema = this.Fragment.GetXbrlSchemaForPrefix(ScenarioNode.Prefix);
         if (NodeSchema != null)
         {
             Element NodeElement = NodeSchema.GetElement(ScenarioNode.LocalName);
             if (NodeElement != null)
             {
                 if (NodeElement.SubstitutionGroup != Element.ElementSubstitutionGroup.Unknown)
                 {
                     string        MessageFormat  = AssemblyResources.GetName("ScenarioNodeUsingSubGroupInXBRLNamespace");
                     StringBuilder MessageBuilder = new StringBuilder();
                     MessageBuilder.AppendFormat(MessageFormat, this.Id, ScenarioNode.Name, NodeSchema.Path);
                     this.Fragment.AddValidationError(new ContextValidationError(this, MessageBuilder.ToString()));
                 }
             }
         }
     }
     foreach (INode CurrentChild in ScenarioNode.ChildNodes)
     {
         ValidateScenarioNode(CurrentChild);
     }
 }
예제 #2
0
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 private void GetSchemaElementFromSchema()
 {
     thisSchema = thisParentFragment.Schemas.GetSchemaFromTargetNamespace(this.Namespace, thisParentFragment);
     if (thisSchema == null)
     {
         if (thisParentFragment.Schemas.Count == 0)
         {
             string        MessageFormat        = AssemblyResources.GetName("NoSchemasForFragment");
             StringBuilder MessageFormatBuilder = new StringBuilder();
             MessageFormatBuilder.AppendFormat(MessageFormat);
             thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
         }
         else
         {
             string        MessageFormat        = AssemblyResources.GetName("NoSchemasForNamespace");
             StringBuilder MessageFormatBuilder = new StringBuilder();
             MessageFormatBuilder.AppendFormat(MessageFormat, this.Name, this.Namespace);
             thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
         }
     }
     this.SchemaElement = thisParentFragment.Schemas.GetElement(this.Name);
     if (this.SchemaElement == null)
     {
         string        MessageFormat        = AssemblyResources.GetName("CannotFindFactElementInSchema");
         StringBuilder MessageFormatBuilder = new StringBuilder();
         MessageFormatBuilder.AppendFormat(MessageFormat, this.Name, thisSchema.SchemaReferencePath);
         thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
     }
 }
예제 #3
0
파일: Item.cs 프로젝트: Mihailorama/gepsio
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 private void GetSchemaElementFromSchema()
 {
     foreach (XbrlSchema CurrentSchema in thisParentFragment.Schemas)
     {
         if (CurrentSchema.TargetNamespace == this.Namespace)
         {
             thisSchema = CurrentSchema;
         }
     }
     if (thisSchema == null)
     {
         if (thisParentFragment.Schemas.Count == 0)
         {
             string        MessageFormat        = AssemblyResources.GetName("NoSchemasForFragment");
             StringBuilder MessageFormatBuilder = new StringBuilder();
             MessageFormatBuilder.AppendFormat(MessageFormat);
             thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
         }
         thisSchema = thisParentFragment.Schemas[0];
     }
     this.SchemaElement = thisSchema.GetElement(this.Name);
     if (this.SchemaElement == null)
     {
         string        MessageFormat        = AssemblyResources.GetName("CannotFindFactElementInSchema");
         StringBuilder MessageFormatBuilder = new StringBuilder();
         MessageFormatBuilder.AppendFormat(MessageFormat, this.Name, thisSchema.Path);
         thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
     }
 }
예제 #4
0
 internal Footnote(FootnoteLink ParentLink, INode FootnoteNode)
 {
     thisFootnoteNode = FootnoteNode;
     this.Link        = ParentLink;
     this.Text        = thisFootnoteNode.FirstChild.Value;
     this.Culture     = null;
     foreach (IAttribute CurrentAttribute in thisFootnoteNode.Attributes)
     {
         if (CurrentAttribute.LocalName.Equals("title") == true)
         {
             this.Title = CurrentAttribute.Value;
         }
         else if (CurrentAttribute.LocalName.Equals("label") == true)
         {
             this.Label = CurrentAttribute.Value;
         }
         else if (CurrentAttribute.LocalName.Equals("lang") == true)
         {
             this.Culture = new CultureInfo(CurrentAttribute.Value);
         }
     }
     if (this.Culture == null)
     {
         StringBuilder MessageBuilder = new StringBuilder();
         string        StringFormat   = AssemblyResources.GetName("NoLangForFootnote");
         MessageBuilder.AppendFormat(StringFormat, this.Label);
         this.Link.Fragment.AddValidationError(new FootnoteValidationError(this, MessageBuilder.ToString()));
     }
 }
예제 #5
0
        private void ValidateSegmentInnerText(INode SegmentNode)
        {
            var text = SegmentNode.InnerText;

            if (string.IsNullOrEmpty(text) == true)
            {
                return;
            }
            if (this.Fragment.Schemas.Count == 0)
            {
                return;
            }
            var schema          = this.Fragment.Schemas[0];
            var segmentNodeType = schema.GetNodeType(SegmentNode);

            if (segmentNodeType == null)
            {
                return;
            }
            if (segmentNodeType.CanConvert(text) == false)
            {
                string        MessageFormat  = AssemblyResources.GetName("SegmentTextNotConvertable");
                StringBuilder MessageBuilder = new StringBuilder();
                MessageBuilder.AppendFormat(MessageFormat, text);
                this.Fragment.AddValidationError(new ContextValidationError(this, MessageBuilder.ToString()));
            }
        }
예제 #6
0
파일: Item.cs 프로젝트: Mihailorama/gepsio
        private void ValidateMonetaryType()
        {
            if (UnitRef == null)
            {
                return;
            }

            // According to Table 3 in section 4.8.2 of the XBRL spec, monetary item units cannot use
            // ratios; they must be single measures. This condition is checked by test 304.26 in the
            // XBRL-CONF-CR5-2012-01-24 conformance suite.

            if (UnitRef.Ratio == true)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("RatioFoundInMonetaryItemUnit");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }

            // Validate the unit's measure, if it exists.

            if (UnitRef.MeasureQualifiedNames.Count == 0)
            {
                return;
            }
            if (UnitRef.MeasureQualifiedNames[0] == null)
            {
                return;
            }

            string Uri = UnitRef.MeasureQualifiedNames[0].NamespaceUri;

            if (Uri == null)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("WrongMeasureNamespaceForMonetaryFact");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id, "unspecified");
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }
            if ((Uri.Length > 0) && (Uri.Equals(XbrlDocument.XbrlIso4217NamespaceUri) == false))
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("WrongMeasureNamespaceForMonetaryFact");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id, UnitRef.MeasureQualifiedNames[0].NamespaceUri);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }
            UnitRef.SetCultureAndRegionInfoFromISO4217Code(UnitRef.MeasureQualifiedNames[0].LocalName);
            if ((UnitRef.CultureInformation == null) && (UnitRef.RegionInformation == null))
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("UnsupportedISO4217CodeForUnitMeasure");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id, UnitRef.MeasureQualifiedNames[0].LocalName);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
            }
        }
예제 #7
0
 private void ValidateSegmentNodeNamespace(INode SegmentNode)
 {
     if (SegmentNode.NamespaceURI.Equals(XbrlDocument.XbrlNamespaceUri) == true)
     {
         string        MessageFormat  = AssemblyResources.GetName("SegmentNodeUsingXBRLNamespace");
         StringBuilder MessageBuilder = new StringBuilder();
         MessageBuilder.AppendFormat(MessageFormat, this.Id, SegmentNode.Name);
         this.Fragment.AddValidationError(new ContextValidationError(this, MessageBuilder.ToString()));
     }
 }
예제 #8
0
파일: Item.cs 프로젝트: Mihailorama/gepsio
 private void ValidateNilDecimalType()
 {
     if ((PrecisionSpecified == true) || (DecimalsSpecified == true))
     {
         string        MessageFormat        = AssemblyResources.GetName("NilNumericFactWithSpecifiedPrecisionOrDecimals");
         StringBuilder MessageFormatBuilder = new StringBuilder();
         MessageFormatBuilder.AppendFormat(MessageFormat, Name, Id);
         thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
     }
 }
예제 #9
0
파일: Item.cs 프로젝트: Mihailorama/gepsio
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 private void SetItemType(IQualifiedName ItemTypeValue)
 {
     this.Type = thisSchema.GetXmlSchemaType(ItemTypeValue);
     if (this.Type == null)
     {
         string        MessageFormat        = AssemblyResources.GetName("InvalidElementItemType");
         StringBuilder MessageFormatBuilder = new StringBuilder();
         MessageFormatBuilder.AppendFormat(MessageFormat, thisSchema.Path, ItemTypeValue.Name, this.Name);
         thisParentFragment.AddValidationError(new ItemValidationError(this, MessageFormatBuilder.ToString()));
     }
 }
예제 #10
0
 private void ValidatePeriod()
 {
     if ((this.PeriodStartDate != System.DateTime.MinValue) && (this.PeriodEndDate != System.DateTime.MinValue))
     {
         if (this.PeriodEndDate < this.PeriodStartDate)
         {
             string        MessageFormat  = AssemblyResources.GetName("PeriodEndDateLessThanPeriodStartDate");
             StringBuilder MessageBuilder = new StringBuilder();
             MessageBuilder.AppendFormat(MessageFormat, this.Id);
             this.Fragment.AddValidationError(new ContextValidationError(this, MessageBuilder.ToString()));
         }
     }
 }
예제 #11
0
파일: Unit.cs 프로젝트: Mihailorama/gepsio
 private void CheckForMeasuresCommonToNumeratorsAndDenominators()
 {
     foreach (QualifiedName CurrentNumeratorMeasure in thisRatioNumeratorQualifiedNames)
     {
         if (thisRatioDenominatorQualifiedNames.Contains(CurrentNumeratorMeasure) == true)
         {
             string        MessageFormat        = AssemblyResources.GetName("UnitRatioUsesSameMeasureInNumeratorAndDenominator");
             StringBuilder MessageFormatBuilder = new StringBuilder();
             MessageFormatBuilder.AppendFormat(MessageFormat, this.Id, CurrentNumeratorMeasure.ToString());
             this.Fragment.AddValidationError(new UnitValidationError(this, MessageFormatBuilder.ToString()));
             return;
         }
     }
 }
예제 #12
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        internal XbrlSchema(XbrlFragment ContainingXbrlFragment, string SchemaFilename, string BaseDirectory)
        {
            this.Fragment = ContainingXbrlFragment;
            this.Path     = GetFullSchemaPath(SchemaFilename, BaseDirectory);

            try
            {
                thisXmlSchema    = Container.Resolve <ISchema>();
                thisXmlSchemaSet = Container.Resolve <ISchemaSet>();
                if (thisXmlSchema.Read(this.Path) == false)
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("SchemaFileCandidateDoesNotContainSchemaRootNode");
                    MessageBuilder.AppendFormat(StringFormat, this.Path);
                    this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString()));
                    return;
                }
                thisXmlSchemaSet.Add(thisXmlSchema);
                thisXmlSchemaSet.Compile();
            }
            catch (FileNotFoundException fnfEx)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("FileNotFoundDuringSchemaCreation");
                MessageBuilder.AppendFormat(StringFormat, this.Path);
                this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString(), fnfEx));
                return;
            }
            catch (WebException webEx)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("WebExceptionThrownDuringSchemaCreation");
                MessageBuilder.AppendFormat(StringFormat, this.Path);
                this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString(), webEx));
                return;
            }

            thisSchemaDocument         = Container.Resolve <IDocument>();
            this.thisLinkbaseDocuments = new List <LinkbaseDocument>();
            this.RoleTypes             = new List <RoleType>();
            thisSchemaDocument.Load(this.Path);
            this.NamespaceManager          = Container.Resolve <INamespaceManager>();
            this.NamespaceManager.Document = thisSchemaDocument;
            this.NamespaceManager.AddNamespace("schema", XbrlSchema.XmlSchemaNamespaceUri);
            ReadSchemaNode();
            ReadSimpleTypes();
            ReadComplexTypes();
            ReadElements();
            LookForAnnotations();
        }
예제 #13
0
 /// <summary>
 /// Reads a schema and compiles it into a schema set.
 /// </summary>
 /// <remarks>
 /// This code may throw exceptions. Exception handling is the responsibility of the caller.
 /// </remarks>
 /// <param name="schemaPath">
 /// The path of the schema to read.
 /// </param>
 /// <returns>
 /// True if the load was successful, false if the file is not a schema file.
 /// </returns>
 private bool ReadAndCompile(string schemaPath)
 {
     thisXmlSchema    = Container.Resolve <ISchema>();
     thisXmlSchemaSet = Container.Resolve <ISchemaSet>();
     if (thisXmlSchema.Read(schemaPath) == false)
     {
         StringBuilder MessageBuilder = new StringBuilder();
         string        StringFormat   = AssemblyResources.GetName("SchemaFileCandidateDoesNotContainSchemaRootNode");
         MessageBuilder.AppendFormat(StringFormat, schemaPath);
         this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString()));
         return(false);
     }
     thisXmlSchemaSet.Add(thisXmlSchema);
     thisXmlSchemaSet.Compile();
     return(true);
 }
예제 #14
0
파일: Item.cs 프로젝트: Mihailorama/gepsio
        /// <summary>
        /// Validate shares item types.
        /// </summary>
        private void ValidateSharesType()
        {
            bool   SharesMeasureFound   = true;
            string UnitMeasureLocalName = string.Empty;
            Unit   UnitReference        = UnitRef;

            if (UnitReference.MeasureQualifiedNames.Count != 1)
            {
                SharesMeasureFound = false;
            }
            if (SharesMeasureFound == true)
            {
                UnitMeasureLocalName = UnitReference.MeasureQualifiedNames[0].LocalName;
                SharesMeasureFound   = UnitMeasureLocalName.Equals("shares");
            }
            if (SharesMeasureFound == false)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("SharesItemTypeUnitLocalNameNotShares");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitReference.Id, UnitMeasureLocalName);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }
            var    SharesNamespaceCorrect = true;
            string Uri = UnitReference.MeasureQualifiedNames[0].NamespaceUri;

            if (string.IsNullOrEmpty(Uri) == true)
            {
                SharesNamespaceCorrect = false;
            }
            else if (Uri.Equals(XbrlDocument.XbrlNamespaceUri) == false)
            {
                SharesNamespaceCorrect = false;
            }
            if (SharesNamespaceCorrect == false)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("WrongMeasureNamespaceForSharesFact");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitReference.Id, Uri);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
            }
        }
예제 #15
0
 private void ValidateSegmentNodePrefix(INode SegmentNode)
 {
     if (SegmentNode.Prefix.Length > 0)
     {
         XbrlSchema NodeSchema = this.Fragment.GetXbrlSchemaForPrefix(SegmentNode.Prefix);
         if (NodeSchema != null)
         {
             Element NodeElement = NodeSchema.GetElement(SegmentNode.LocalName);
             if (NodeElement != null)
             {
                 if (NodeElement.SubstitutionGroup != Element.ElementSubstitutionGroup.Unknown)
                 {
                     string        MessageFormat  = AssemblyResources.GetName("SegmentNodeUsingSubGroupInXBRLNamespace");
                     StringBuilder MessageBuilder = new StringBuilder();
                     MessageBuilder.AppendFormat(MessageFormat, this.Id, SegmentNode.Name, NodeSchema.Path);
                     this.Fragment.AddValidationError(new ContextValidationError(this, MessageBuilder.ToString()));
                 }
             }
         }
     }
 }
예제 #16
0
 /// <summary>
 /// Reads the schema's root node and collects namespace data from the namespace attributes.
 /// </summary>
 private void ReadSchemaNode()
 {
     this.Elements       = new List <Element>();
     this.SchemaRootNode = thisSchemaDocument.SelectSingleNode("//schema:schema", this.NamespaceManager);
     if (this.SchemaRootNode == null)
     {
         StringBuilder MessageBuilder = new StringBuilder();
         string        StringFormat   = AssemblyResources.GetName("SchemaFileCandidateDoesNotContainSchemaRootNode");
         MessageBuilder.AppendFormat(StringFormat, this.Path);
         this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString()));
         return;
     }
     this.TargetNamespace = this.SchemaRootNode.Attributes["targetNamespace"].Value;
     foreach (IAttribute CurrentAttribute in this.SchemaRootNode.Attributes)
     {
         if (CurrentAttribute.Prefix == "xmlns")
         {
             this.NamespaceManager.AddNamespace(CurrentAttribute.LocalName, CurrentAttribute.Value);
         }
     }
 }
예제 #17
0
파일: Item.cs 프로젝트: Mihailorama/gepsio
        /// <summary>
        /// Validate pure item types.
        /// </summary>
        private void ValidatePureType()
        {
            string UnitMeasureLocalName = string.Empty;
            Unit   UnitReference        = UnitRef;
            bool   PureMeasureFound     = true;

            if (UnitReference.MeasureQualifiedNames.Count != 1)
            {
                PureMeasureFound = false;
            }
            if (PureMeasureFound == true)
            {
                UnitMeasureLocalName = UnitReference.MeasureQualifiedNames[0].LocalName;
                PureMeasureFound     = UnitMeasureLocalName.Equals("pure");
            }
            if (PureMeasureFound == false)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("PureItemTypeUnitLocalNameNotPure");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitReference.Id, UnitMeasureLocalName);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
            }
        }
예제 #18
0
        /// <summary>
        /// Validates a given summation concept.
        /// </summary>
        /// <param name="CurrentCalculationLink">
        /// The calculation link that defines the given summation concept.
        /// </param>
        /// <param name="CurrentSummationConcept">
        /// The summation concept to be validated.
        /// </param>
        /// <param name="FactList">
        /// The collection of items that should be searched when looking for summation or contributing items.
        /// </param>
        private void ValidateSummationConcept(CalculationLink CurrentCalculationLink, SummationConcept CurrentSummationConcept, FactCollection FactList)
        {
            Element SummationConceptElement = LocateElement(CurrentSummationConcept.SummationConceptLocator);
            Item    SummationConceptItem    = LocateItem(SummationConceptElement, FactList);

            // If the summation concept item doesn't exist, then there is no calculation
            // to perform.

            if (SummationConceptItem == null)
            {
                return;
            }

            // If the summation concept item has a "nil" value, then there is no calculation
            // to perform.

            if (SummationConceptItem.NilSpecified == true)
            {
                return;
            }

            double SummationConceptRoundedValue         = SummationConceptItem.RoundedValue;
            double ContributingConceptRoundedValueTotal = 0;
            var    ContributingConceptItemsFound        = false;

            foreach (Locator CurrentLocator in CurrentSummationConcept.ContributingConceptLocators)
            {
                // Some decisions need to be made before the code can actually add the value of the
                // contributing concept to the total that the code is keeping.

                var IncludeContributingConceptItemInCalculation = true;

                // Find the calculation arc for the given calculation link.

                CalculationArc ContributingConceptCalculationArc = CurrentCalculationLink.GetCalculationArc(CurrentLocator);
                if (ContributingConceptCalculationArc == null)
                {
                    IncludeContributingConceptItemInCalculation = false;
                }

                // Find the elemement for the given locator.

                Element ContributingConceptElement = LocateElement(CurrentLocator);
                if (ContributingConceptElement == null)
                {
                    IncludeContributingConceptItemInCalculation = false;
                }

                // Find all items for the given element. If there is more than one, and at least
                // one of them is not p-equals with at least one of the other ones, then
                // the entire calculation validation is forfeit, according to test 397.12 in
                // the XBRL-CONF-CR3-2007-03-05 conformance suite.

                var AllMatchingItems = LocateItems(ContributingConceptElement, FactList);
                if (AllItemsNotPEquals(AllMatchingItems) == false)
                {
                    return;
                }

                // Find the item for the given element.

                if (AllMatchingItems.Count == 0)
                {
                    IncludeContributingConceptItemInCalculation = false;
                }
                else
                {
                    foreach (var ContributingConceptItem in AllMatchingItems)
                    {
                        // Ensure that the contributing concept item is context-equals
                        // with the summation item.

                        if (IncludeContributingConceptItemInCalculation == true)
                        {
                            if (SummationConceptItem.ContextEquals(ContributingConceptItem) == false)
                            {
                                IncludeContributingConceptItemInCalculation = false;
                            }
                        }

                        // Ensure that the contributing concept item is unit-equals
                        // with the summation item.

                        if (IncludeContributingConceptItemInCalculation == true)
                        {
                            if (SummationConceptItem.UnitEquals(ContributingConceptItem) == false)
                            {
                                IncludeContributingConceptItemInCalculation = false;
                            }
                        }

                        // Ensure that the contributing concept item does not have a nil value.

                        if (IncludeContributingConceptItemInCalculation == true)
                        {
                            if (ContributingConceptItem.NilSpecified == true)
                            {
                                IncludeContributingConceptItemInCalculation = false;
                            }
                        }

                        // If the code is still interested in including the contributing concept item
                        // in the calculation, then get its rounded value and add it to the total.

                        if (IncludeContributingConceptItemInCalculation == true)
                        {
                            ContributingConceptItemsFound = true;
                            double ContributingConceptRoundedValue = ContributingConceptItem.RoundedValue;
                            if (ContributingConceptCalculationArc.Weight != (decimal)(1.0))
                            {
                                ContributingConceptRoundedValue = ContributingConceptRoundedValue * (double)(ContributingConceptCalculationArc.Weight);
                            }
                            ContributingConceptRoundedValueTotal += ContributingConceptRoundedValue;
                        }
                    }
                }
            }
            if (ContributingConceptItemsFound == true)
            {
                ContributingConceptRoundedValueTotal = SummationConceptItem.Round(ContributingConceptRoundedValueTotal);
                if (SummationConceptRoundedValue != ContributingConceptRoundedValueTotal)
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("SummationConceptError");
                    MessageBuilder.AppendFormat(StringFormat, SummationConceptItem.Name, SummationConceptRoundedValue, ContributingConceptRoundedValueTotal);
                    ValidatedFragment.AddValidationError(new SummationConceptValidationError(CurrentSummationConcept, MessageBuilder.ToString()));
                    return;
                }
            }
        }
예제 #19
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        internal XbrlSchema(XbrlFragment ContainingXbrlFragment, string SchemaFilename, string BaseDirectory)
        {
            this.Fragment            = ContainingXbrlFragment;
            this.SchemaReferencePath = GetFullSchemaPath(SchemaFilename, BaseDirectory);
            this.LoadPath            = this.SchemaReferencePath;
            try
            {
                if (ReadAndCompile(this.SchemaReferencePath) == false)
                {
                    return;
                }
            }
            catch (FileNotFoundException fnfEx)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("FileNotFoundDuringSchemaCreation");
                MessageBuilder.AppendFormat(StringFormat, this.SchemaReferencePath);
                this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString(), fnfEx));
                return;
            }
            catch (WebException webEx)
            {
                // Check to see if we got an HTTP 404 back from an attempt to open a schema up from a
                // URL. If we did, check to see if the schema is available locally. Some taxonomies are
                // specified through URLs that don't actually exist in a physical form but just appear
                // as placeholders. The Dutch taxonomies are an example of this. An XBRL instance might
                // have a schema reference of "http://archprod.service.eogs.dk/taxonomy/20171001/
                // entryDanishGAAPBalanceSheetAccountFormIncomeStatementByNatureIncludingManagements
                // ReviewStatisticsAndTax20171001.xsd", for example, but there might not be a schema
                // at that location. It is assumed, in these cases, that the schema is available with
                // the XBRL instance itself. Check for a locally-stored schema.

                var localSchemaAvailable = false;
                var schemaLocalPath      = string.Empty;
                var webResponse          = webEx.Response as HttpWebResponse;
                if (webResponse == null || webResponse.StatusCode == HttpStatusCode.NotFound)
                {
                    schemaLocalPath = BuildSchemaPathLocalToFragment(ContainingXbrlFragment, SchemaFilename);
                    try
                    {
                        localSchemaAvailable = ReadAndCompile(schemaLocalPath);
                    }
                    catch (FileNotFoundException)
                    {
                        localSchemaAvailable = false;
                    }
                }
                if (localSchemaAvailable == false)
                {
                    StringBuilder MessageBuilder = new StringBuilder();
                    string        StringFormat   = AssemblyResources.GetName("WebExceptionThrownDuringSchemaCreation");
                    MessageBuilder.AppendFormat(StringFormat, this.SchemaReferencePath);
                    this.Fragment.AddValidationError(new SchemaValidationError(this, MessageBuilder.ToString(), webEx));
                    return;
                }
                this.LoadPath = schemaLocalPath;
            }
            thisSchemaDocument         = Container.Resolve <IDocument>();
            this.thisLinkbaseDocuments = new LinkbaseDocumentCollection();
            this.RoleTypes             = new List <RoleType>();
            thisSchemaDocument.Load(this.LoadPath);
            this.NamespaceManager          = Container.Resolve <INamespaceManager>();
            this.NamespaceManager.Document = thisSchemaDocument;
            this.NamespaceManager.AddNamespace("schema", XbrlSchema.XmlSchemaNamespaceUri);
            ReadSchemaNode();
            ReadSimpleTypes();
            ReadComplexTypes();
            ReadElements();
            LookForAnnotations();
        }