Esempio n. 1
0
        //)
        internal Report(XbrlFragment Fragment, IEnumerable<XmlElement> ReportNodes)
        {
            this.Fragment = Fragment;

            //thisContextNode = ContextNode;
            //this.Id = thisContextNode.Attributes["id"].Value;
            //this.PeriodStartDate = System.DateTime.MinValue;
            //this.PeriodEndDate = System.DateTime.MinValue;
            //foreach (XmlNode CurrentChild in thisContextNode.ChildNodes)
            foreach (XmlNode CurrentChild in ReportNodes)
            {
                switch (CurrentChild.LocalName)
                {
                    case "genInfo.report.id":
                        ReportID = Convert.ToInt64(CurrentChild.InnerText);
                        break;
                    case "genInfo.report.id.accordingTo.yearEnd":
                        AccordingToYearEnd = Convert.ToDateTime(CurrentChild.InnerText);
                        break;
                    case "genInfo.report.id.reportType":
                        ReportType = CurrentChild.InnerText;
                        break;
                }

            }
        }
Esempio n. 2
0
 internal Unit(XbrlFragment fragment, INode UnitNode, INamespaceManager namespaceManager)
 {
     this.Fragment          = fragment;
     this.RegionInformation = null;
     thisUnitNode           = UnitNode;
     this.Id = thisUnitNode.Attributes["id"].Value;
     this.MeasureQualifiedNames = new List <QualifiedName>();
     this.Ratio = false;
     thisRatioNumeratorQualifiedNames   = new List <QualifiedName>();
     thisRatioDenominatorQualifiedNames = new List <QualifiedName>();
     this.namespaceManager = namespaceManager;
     foreach (INode CurrentChild in UnitNode.ChildNodes)
     {
         if (CurrentChild.LocalName.Equals("measure") == true)
         {
             this.MeasureQualifiedNames.Add(new QualifiedName(CurrentChild, namespaceManager));
         }
         else if (CurrentChild.LocalName.Equals("divide") == true)
         {
             ProcessDivideChildElement(CurrentChild);
             CheckForMeasuresCommonToNumeratorsAndDenominators();
             this.Ratio = true;
         }
     }
 }
Esempio n. 3
0
        internal static Fact Create(XbrlFragment ParentFragment, INode FactNode)
        {
            Fact FactToReturn = null;

            if ((IsXbrlNamespace(FactNode.NamespaceURI) == false) &&
                (IsW3Namespace(FactNode.NamespaceURI) == false) &&
                (FactNode.IsComment == false))
            {
                // This item could be a fact, or it could be a tuple. Examine the schemas
                // to find out what we're dealing with.

                var MatchingElement = ParentFragment.Schemas.GetElement(FactNode.LocalName);
                if (MatchingElement != null)
                {
                    switch (MatchingElement.SubstitutionGroup)
                    {
                    case Element.ElementSubstitutionGroup.Item:
                        FactToReturn = new Item(ParentFragment, FactNode);
                        break;

                    case Element.ElementSubstitutionGroup.Tuple:
                        FactToReturn = new Tuple(ParentFragment, FactNode);
                        break;

                    default:
                        // This type is unknown, so leave it alone.
                        break;
                    }
                }
            }
            return(FactToReturn);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the schema having the target namespace.
        /// </summary>
        /// <param name="targetNamespace">
        /// The namespace whose schema should be returned.
        /// </param>
        /// <param name="parentFragment">
        /// The fragment containing the schema reference.
        /// </param>
        /// <returns>
        /// A reference to the schema matching the target namespace. A null reference will be returned
        /// if no matching schema can be found.
        /// </returns>
        public XbrlSchema GetSchemaFromTargetNamespace(string targetNamespace, XbrlFragment parentFragment)
        {
            var foundSchema = FindSchema(targetNamespace);

            if (foundSchema == null)
            {
                // There is no loaded schema for the target namespace. The target
                // namespace be an industry-standard namespace referencing a schema
                // that has not been explicitly loaded. Find out if the namespace is
                // a standard one, and, if so, load its corresponding schema and
                // retry the search.

                string schemaLocation;
                StandardNamespaceSchemaLocationDictionary.TryGetValue(targetNamespace, out schemaLocation);
                if (string.IsNullOrEmpty(schemaLocation) == true)
                {
                    return(null);
                }
                var newSchema = new XbrlSchema(parentFragment, schemaLocation, string.Empty);
                newSchema.TargetNamespaceAlias = targetNamespace;
                Add(newSchema);
                foundSchema = FindSchema(targetNamespace);
            }
            return(foundSchema);
        }
Esempio n. 5
0
        /// <summary>
        /// Checks to see if the current arc is equivalent to a supplied arc.
        /// </summary>
        /// <remarks>
        /// Equivalency is determined using the rules in section 3.5.3.9.7.4 of the XBRL Specification.
        /// </remarks>
        /// <param name="otherArc">
        /// The other arc to compare to this arc.
        /// </param>
        /// <param name="containingFragment">
        /// The fragment containing the arc.
        /// </param>
        /// <returns>
        /// True if the arcs are equivalent; false if the arcs are not equivalent.
        /// </returns>
        internal bool EquivalentTo(Arc otherArc, XbrlFragment containingFragment)
        {
            var nonExemptAttributesForThisArc  = GetNonExemptAttributes(this);
            var nonExemptAttributesForOtherArc = GetNonExemptAttributes(otherArc);

            if (nonExemptAttributesForThisArc.Count != nonExemptAttributesForOtherArc.Count)
            {
                return(false);
            }
            foreach (var thisArcAttribute in nonExemptAttributesForThisArc)
            {
                var matchingAttribute = nonExemptAttributesForOtherArc.FirstOrDefault(a => a.LocalName.Equals(thisArcAttribute.LocalName));
                if (matchingAttribute == null)
                {
                    return(false);
                }
                if (thisArcAttribute.NamespaceURI.Equals(matchingAttribute.NamespaceURI) == false)
                {
                    return(false);
                }
                if (thisArcAttribute.TypedValueEquals(matchingAttribute, containingFragment) == false)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 6
0
        //------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------
        internal Item(XbrlFragment ParentFragment, INode ItemNode) : base(ParentFragment, ItemNode)
        {
            this.ContextRefName        = thisFactNode.GetAttributeValue("contextRef");
            this.UnitRefName           = thisFactNode.GetAttributeValue("unitRef");
            thisRoundedValueCalculated = false;
            this.NilSpecified          = false;
            string NilValue = thisFactNode.GetAttributeValue(XbrlSchema.XmlSchemaInstanceNamespaceUri, "nil");

            if (NilValue.Equals("true", StringComparison.CurrentCultureIgnoreCase) == true)
            {
                this.NilSpecified = true;
            }
            GetSchemaElementFromSchema();
            this.Value = thisFactNode.InnerText;
            if (SchemaElement.SubstitutionGroup == Element.ElementSubstitutionGroup.Item)
            {
                SetItemType(SchemaElement.TypeName);
            }
            SetDecimals();
            SetPrecision();
            if (string.IsNullOrEmpty(thisPrecisionAttributeValue) == true)
            {
                InferPrecision();
            }
        }
Esempio n. 7
0
 internal Fact(XbrlFragment ParentFragment, INode FactNode)
 {
     thisParentFragment = ParentFragment;
     thisFactNode       = FactNode;
     this.Name          = thisFactNode.LocalName;
     this.Id            = thisFactNode.GetAttributeValue("id");
 }
Esempio n. 8
0
 //------------------------------------------------------------------------------------
 // Returns true if this Fact is Context Equal (c-equal) to a supplied fact, and false
 // otherwise. See section 4.10 of the XBRL 2.1 spec for more information.
 //------------------------------------------------------------------------------------
 internal bool ContextEquals(Item OtherFact, XbrlFragment containingFragment)
 {
     if (Object.ReferenceEquals(this.ContextRef, OtherFact.ContextRef) == true)
     {
         return(true);
     }
     return(this.ContextRef.StructureEquals(OtherFact.ContextRef, containingFragment));
 }
Esempio n. 9
0
        /// <summary>
        /// Builds a schema path local to a given fragment, ignoring any existing path information
        /// in the supplied schema path.
        /// </summary>
        /// <param name="ContainingXbrlFragment"></param>
        /// <param name="SchemaFilename"></param>
        /// <returns></returns>
        private string BuildSchemaPathLocalToFragment(XbrlFragment ContainingXbrlFragment, string SchemaFilename)
        {
            var schemaUri         = new Uri(SchemaFilename);
            var schemaUriSegments = schemaUri.Segments.Length;
            var schemaUriFilename = schemaUri.Segments[schemaUriSegments - 1];
            var localPath         = ContainingXbrlFragment.Document.Path;
            var schemaLocalPath   = System.IO.Path.Combine(localPath, schemaUriFilename);

            return(schemaLocalPath);
        }
Esempio n. 10
0
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 internal LinkbaseDocument(string ContainingDocumentUri, string DocumentPath, XbrlFragment containingFragment)
 {
     thisLinkbasePath = GetFullLinkbasePath(ContainingDocumentUri, DocumentPath);
     thisXmlDocument  = Container.Resolve <IDocument>();
     thisXmlDocument.Load(thisLinkbasePath);
     thisNamespaceManager          = Container.Resolve <INamespaceManager>();
     thisNamespaceManager.Document = thisXmlDocument;
     thisNamespaceManager.AddNamespace("default", XbrlDocument.XbrlLinkbaseNamespaceUri);
     thisLinkbaseNode = thisXmlDocument.SelectSingleNode("//default:linkbase", thisNamespaceManager);
 }
Esempio n. 11
0
 internal Tuple(XbrlFragment ParentFragment, XmlNode TupleNode)
     : base(ParentFragment, TupleNode)
 {
     this.Facts = new List<Fact>();
     foreach (XmlNode CurrentChild in TupleNode.ChildNodes)
     {
         var CurrentFact = Fact.Create(ParentFragment, CurrentChild);
         if (CurrentFact != null)
             this.Facts.Add(CurrentFact);
     }
 }
Esempio n. 12
0
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 private bool EntityStructureEquals(Context OtherContext, XbrlFragment containingFragment)
 {
     if (this.Identifier.Equals(OtherContext.Identifier) == false)
     {
         return(false);
     }
     if (SegmentStructureEquals(OtherContext, containingFragment) == false)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 13
0
 internal Tuple(XbrlFragment ParentFragment, INode TupleNode) : base(ParentFragment, TupleNode)
 {
     this.Facts = new FactCollection();
     foreach (INode CurrentChild in TupleNode.ChildNodes)
     {
         var CurrentFact = Fact.Create(ParentFragment, CurrentChild);
         if (CurrentFact != null)
         {
             this.Facts.Add(CurrentFact);
         }
     }
 }
Esempio n. 14
0
        //------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------
        internal Item(XbrlFragment ParentFragment, XmlNode ItemNode)
            : base(ParentFragment, ItemNode)
        {
            this.ContextRefName = XmlUtilities.GetAttributeValue(thisFactNode, "contextRef");
            this.UnitRefName = XmlUtilities.GetAttributeValue(thisFactNode, "unitRef");
            thisRoundedValueCalculated = false;

            thisDecimalsAttributeValue = XmlUtilities.GetAttributeValue(thisFactNode, "decimals");
            if (thisDecimalsAttributeValue.Length > 0)
            {
                if (thisDecimalsAttributeValue.Equals("INF") == true)
                {
                    this.InfiniteDecimals = true;
                    this.Decimals = 0;
                }
                else
                {
                    this.InfiniteDecimals = false;
                    this.Decimals = Convert.ToInt32(thisDecimalsAttributeValue);
                }
            }

            thisPrecisionAttributeValue = XmlUtilities.GetAttributeValue(thisFactNode, "precision");
            if (thisPrecisionAttributeValue.Length > 0)
            {
                this.PrecisionInferred = false;
                if (thisPrecisionAttributeValue.Equals("INF") == true)
                {
                    this.InfinitePrecision = true;
                    this.Precision = 0;
                }
                else
                {
                    this.InfinitePrecision = false;
                    this.Precision = Convert.ToInt32(thisPrecisionAttributeValue);
                }
            }

            this.Id = XmlUtilities.GetAttributeValue(thisFactNode, "id");
            this.NilSpecified = false;
            string NilValue = XmlUtilities.GetAttributeValue(thisFactNode, "http://www.w3.org/2001/XMLSchema-instance", "nil");
            if (NilValue.Equals("true", StringComparison.CurrentCultureIgnoreCase) == true)
                this.NilSpecified = true;
            GetSchemaElementFromSchema();
            this.Value = thisFactNode.InnerText;
            if (SchemaElement.SubstitutionGroup == Element.ElementSubstitutionGroup.Item)
                SetItemType(SchemaElement.TypeName);

            if (thisPrecisionAttributeValue.Length == 0)
                InferPrecision();
        }
Esempio n. 15
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();
        }
Esempio n. 16
0
 /// <summary>
 /// Process a node by looking for a schemaLocation attribute and processing it if it is found.
 /// </summary>
 /// <param name="node">
 /// A node which may contain a schemaLocation attribute.
 /// </param>
 /// <param name="fragment">
 /// The XBRL fragment containing the node.
 /// </param>
 internal static void Process(INode node, XbrlFragment fragment)
 {
     foreach (IAttribute currentAttribute in node.Attributes)
     {
         if ((currentAttribute.NamespaceURI.Equals(XbrlDocument.XmlSchemaInstanceUri) == true) && (currentAttribute.LocalName.Equals("schemaLocation") == true))
         {
             var attributeValue = currentAttribute.Value.Trim();
             if (string.IsNullOrEmpty(attributeValue) == false)
             {
                 ProcessSchemaLocationAttributeValue(attributeValue, fragment);
             }
         }
     }
 }
Esempio n. 17
0
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 private bool ScenarioStructureEquals(Context OtherContext, XbrlFragment containingFragment)
 {
     if ((this.Scenario == null) && (OtherContext.Scenario == null))
     {
         return(true);
     }
     if ((this.Scenario == null) && (OtherContext.Scenario != null))
     {
         return(false);
     }
     if ((this.Scenario != null) && (OtherContext.Scenario == null))
     {
         return(false);
     }
     return(this.Scenario.StructureEquals(OtherContext.Scenario, containingFragment));
 }
Esempio n. 18
0
 //------------------------------------------------------------------------------------
 // Returns true if this context is Structure Equal (s-equal) to a supplied context,
 // and false otherwise. See section 4.10 of the XBRL 2.1 spec for more information.
 //------------------------------------------------------------------------------------
 internal bool StructureEquals(Context OtherContext, XbrlFragment containingFragment)
 {
     if (PeriodStructureEquals(OtherContext) == false)
     {
         return(false);
     }
     if (EntityStructureEquals(OtherContext, containingFragment) == false)
     {
         return(false);
     }
     if (ScenarioStructureEquals(OtherContext, containingFragment) == false)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 19
0
 //------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------
 private bool SegmentStructureEquals(Context OtherContext, XbrlFragment containingFragment)
 {
     //--------------------------------------------------------------------------------
     // If neither context has a <segment> node, then the segments are considered
     // equal.
     //--------------------------------------------------------------------------------
     if ((this.Segment == null) && (OtherContext.Segment == null))
     {
         return(true);
     }
     //--------------------------------------------------------------------------------
     // If this context does not have a <segment> node, but the other one does, then
     // the segments are equal only if the other <segment> is empty.
     //--------------------------------------------------------------------------------
     if ((this.Segment == null) && (OtherContext.Segment != null))
     {
         if (OtherContext.Segment.ChildNodes.Count > 0)
         {
             return(false);
         }
         return(true);
     }
     //--------------------------------------------------------------------------------
     // If the other context does not have a <segment> node, but this one does, then
     // the segments are equal only if this <segment> is empty.
     //--------------------------------------------------------------------------------
     if ((this.Segment != null) && (OtherContext.Segment == null))
     {
         if (this.Segment.ChildNodes.Count > 0)
         {
             return(false);
         }
         return(true);
     }
     //--------------------------------------------------------------------------------
     // At this point, both segments exist. Check to see if they have the same
     // structure.
     //--------------------------------------------------------------------------------
     return(this.Segment.StructureEquals(OtherContext.Segment, containingFragment));
 }
Esempio n. 20
0
 //-------------------------------------------------------------------------------
 //-------------------------------------------------------------------------------
 internal FootnoteLink(XbrlFragment ParentFragment, INode FootnoteLinkNode)
 {
     thisFootnoteLinkNode  = FootnoteLinkNode;
     this.Fragment         = ParentFragment;
     this.Footnotes        = new List <Footnote>();
     this.FootnoteLocators = new List <FootnoteLocator>();
     this.FootnoteArcs     = new List <FootnoteArc>();
     foreach (INode ChildNode in thisFootnoteLinkNode.ChildNodes)
     {
         if (ChildNode.LocalName.Equals("loc") == true)
         {
             this.FootnoteLocators.Add(new FootnoteLocator(this, ChildNode));
         }
         else if (ChildNode.LocalName.Equals("footnote") == true)
         {
             this.Footnotes.Add(new Footnote(this, ChildNode));
         }
         else if (ChildNode.LocalName.Equals("footnoteArc") == true)
         {
             this.FootnoteArcs.Add(new FootnoteArc(this, ChildNode));
         }
     }
 }
Esempio n. 21
0
 internal Context(XbrlFragment Fragment, INode ContextNode)
 {
     this.Fragment        = Fragment;
     thisContextNode      = ContextNode;
     this.Id              = thisContextNode.Attributes.FindAttribute("id").Value;
     this.PeriodStartDate = System.DateTime.MinValue;
     this.PeriodEndDate   = System.DateTime.MinValue;
     foreach (INode CurrentChild in thisContextNode.ChildNodes)
     {
         if (CurrentChild.LocalName.Equals("period") == true)
         {
             ProcessPeriod(CurrentChild);
         }
         else if (CurrentChild.LocalName.Equals("entity") == true)
         {
             ProcessEntity(CurrentChild);
         }
         else if (CurrentChild.LocalName.Equals("scenario") == true)
         {
             ProcessScenario(CurrentChild);
         }
     }
 }
        private static int GetFiscalYear(string symbol, XbrlFragment frag)
        {
            int yr = 0;
            foreach (XmlAttribute attrib in frag.XbrlRootNode.Attributes)
            {
                if (attrib.LocalName == symbol)
                {
                    yr = Convert.ToInt32(System.IO.Path.GetFileNameWithoutExtension(attrib.Value).Substring(0, 4));
                }
            }

            return yr;
        }
 internal CalculationLinkbaseDocument(string ContainingDocumentUri, string DocumentPath, XbrlFragment containingFragment)
     : base(ContainingDocumentUri, DocumentPath, containingFragment)
 {
     CalculationLinks = new List <CalculationLink>();
     foreach (INode CurrentChild in thisLinkbaseNode.ChildNodes)
     {
         if (CurrentChild.LocalName.Equals("calculationLink") == true)
         {
             this.CalculationLinks.Add(new CalculationLink(this, CurrentChild));
         }
     }
 }
Esempio n. 24
0
 internal SummationConceptValidator(XbrlFragment fragment)
 {
     this.ValidatedFragment = fragment;
 }
Esempio n. 25
0
 internal ReferenceLinkbaseDocument(string ContainingDocumentUri, string DocumentPath, XbrlFragment containingFragment)
     : base(ContainingDocumentUri, DocumentPath, containingFragment)
 {
     ReferenceLinks = new List <ReferenceLink>();
     foreach (INode CurrentChild in thisLinkbaseNode.ChildNodes)
     {
         if (CurrentChild.LocalName.Equals("referenceLink") == true)
         {
             this.ReferenceLinks.Add(new ReferenceLink(CurrentChild));
         }
     }
 }
Esempio n. 26
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();
        }
Esempio n. 27
0
        //------------------------------------------------------------------------------------
        // Used for when a linkbaseRef element has no "role" attribute and the type of linkbase
        // document must be discovered. The 331-equivalentRelationships-instance-02.xml
        // document in the XBRL-CONF-2014-12-10 conformance suite is an example of this need.
        //------------------------------------------------------------------------------------
        internal static LinkbaseDocument Create(string containingDocumentUri, string href, XbrlFragment containingFragment)
        {
            var newLinkbaseDocument = new LinkbaseDocument(containingDocumentUri, href, containingFragment);
            var firstChild          = newLinkbaseDocument.thisLinkbaseNode.FirstChild;

            if (firstChild == null)
            {
                throw new NotSupportedException($"Linkbase node has no child nodes in document {href} at URI {containingDocumentUri}.");
            }
            string firstChildLocalName = firstChild.LocalName;

            firstChild          = null;
            newLinkbaseDocument = null;
            if (firstChildLocalName.Equals("calculationLink"))
            {
                return(new CalculationLinkbaseDocument(containingDocumentUri, href, containingFragment));
            }
            if (firstChildLocalName.Equals("definitionLink"))
            {
                return(new DefinitionLinkbaseDocument(containingDocumentUri, href, containingFragment));
            }
            if (firstChildLocalName.Equals("labelLink"))
            {
                return(new LabelLinkbaseDocument(containingDocumentUri, href, containingFragment));
            }
            if (firstChildLocalName.Equals("presentationLink"))
            {
                return(new PresentationLinkbaseDocument(containingDocumentUri, href, containingFragment));
            }
            if (firstChildLocalName.Equals("referenceLink"))
            {
                return(new ReferenceLinkbaseDocument(containingDocumentUri, href, containingFragment));
            }
            throw new NotSupportedException($"Linkbase node has unsupported child node with local name {firstChildLocalName} in document {href} at URI {containingDocumentUri}.");
        }
Esempio n. 28
0
 /// <summary>
 /// Read linkbase references found in a schema.
 /// </summary>
 /// <param name="ContainingDocumentUri">
 /// The URI of the document containing the linkbase reference.
 /// </param>
 /// <param name="parentNode">
 /// The XML node whose child nodes will be searched for linkbase references.
 /// </param>
 /// <param name="containingFragment">
 /// The XBRL fragment containing the linkbase reference.</param>
 internal void ReadLinkbaseReferences(string ContainingDocumentUri, INode parentNode, XbrlFragment containingFragment)
 {
     foreach (INode CurrentChild in parentNode.ChildNodes)
     {
         if ((CurrentChild.NamespaceURI.Equals(XbrlDocument.XbrlLinkbaseNamespaceUri) == true) && (CurrentChild.LocalName.Equals("linkbaseRef") == true))
         {
             ReadLinkbaseReference(ContainingDocumentUri, CurrentChild, containingFragment);
         }
     }
 }
Esempio n. 29
0
        private static void ProcessSchemaNamespaceAndLocation(string schemaNamespace, string schemaLocation, XbrlFragment containingFragment)
        {
            foreach (var currentSchema in containingFragment.Schemas)
            {
                if (currentSchema.TargetNamespace.Equals(schemaNamespace) == true)
                {
                    return;
                }
                if (currentSchema.TargetNamespaceAlias.Equals(schemaNamespace) == true)
                {
                    return;
                }
            }
            var newSchema = new XbrlSchema(containingFragment, schemaLocation, string.Empty);

            if (newSchema.SchemaRootNode != null)
            {
                containingFragment.Schemas.Add(newSchema);
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Process a value found in a schemaLocation attribute.
        /// </summary>
        /// <remarks>
        /// This string is formatted as a set of whitespace-delimited pairs. The first URI reference in each pair is a namespace name,
        /// and the second is the location of a schema that describes that namespace.
        /// </remarks>
        /// <param name="schemaLocationAttributeValue">
        /// The value of a schemaLocation attribute.
        /// </param>
        /// <param name="containingFragment">
        /// The XBRL fragment containing the attribute.
        /// </param>
        private static void ProcessSchemaLocationAttributeValue(string schemaLocationAttributeValue, XbrlFragment containingFragment)
        {
            var NamespacesAndLocations = schemaLocationAttributeValue.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

            for (var index = 0; index < NamespacesAndLocations.Length; index += 2)
            {
                ProcessSchemaNamespaceAndLocation(NamespacesAndLocations[index], NamespacesAndLocations[index + 1], containingFragment);
            }
        }
Esempio n. 31
0
        private void ReadLinkbaseReference(string ContainingDocumentUri, INode LinkbaseReferenceNode, XbrlFragment containingFragment)
        {
            var xlinkNode = new XlinkNode(LinkbaseReferenceNode);

            if (xlinkNode.IsInRole(XbrlDocument.XbrlCalculationLinkbaseReferenceRoleNamespaceUri) == true)
            {
                this.thisLinkbaseDocuments.Add(new CalculationLinkbaseDocument(ContainingDocumentUri, xlinkNode.Href, containingFragment));
            }
            else if (xlinkNode.IsInRole(XbrlDocument.XbrlDefinitionLinkbaseReferenceRoleNamespaceUri) == true)
            {
                this.thisLinkbaseDocuments.Add(new DefinitionLinkbaseDocument(ContainingDocumentUri, xlinkNode.Href, containingFragment));
            }
            else if (xlinkNode.IsInRole(XbrlDocument.XbrlLabelLinkbaseReferenceRoleNamespaceUri) == true)
            {
                this.thisLinkbaseDocuments.Add(new LabelLinkbaseDocument(ContainingDocumentUri, xlinkNode.Href, containingFragment));
            }
            else if (xlinkNode.IsInRole(XbrlDocument.XbrlPresentationLinkbaseReferenceRoleNamespaceUri) == true)
            {
                this.thisLinkbaseDocuments.Add(new PresentationLinkbaseDocument(ContainingDocumentUri, xlinkNode.Href, containingFragment));
            }
            else if (xlinkNode.IsInRole(XbrlDocument.XbrlReferenceLinkbaseReferenceRoleNamespaceUri) == true)
            {
                this.thisLinkbaseDocuments.Add(new ReferenceLinkbaseDocument(ContainingDocumentUri, xlinkNode.Href, containingFragment));
            }
            else
            {
                // At this point, the role is either not available or not in the list of supported roles.
                // Attempt to use a factory method to look at the linkbase document and attempt to discover
                // the correct document type.

                this.thisLinkbaseDocuments.Add(LinkbaseDocument.Create(ContainingDocumentUri, xlinkNode.Href, containingFragment));
            }
        }