private void LoadReferences( out int numErrors ) { numErrors = 0; if ( dependantTaxonomies.Count == 0 ) { int errs = LoadDependantTaxonomies(this.schemaPath); numErrors += errs; numRefErrors += errs; } if ( referenceFile == null ) { referenceFile = GetLinkbaseReference( TARGET_LINKBASE_URI + REFERENCE_ROLE ); } int errors = 0; if ( referenceTable == null ) { referenceTable = new Hashtable(); } if ( referenceFile != null ) { foreach ( string refFile in referenceFile ) { Reference reference = new Reference(); reference.OwnerHandle = OwnerHandle; reference.loadingTaxonomy = this.GetLoadingTaxonomy(); reference.PromptUser = this.PromptUser; if ( refFile != null ) { reference.Load( refFile, out numErrors ); if (IsAucentExtension && skipAucentExtensions && !this.innerTaxonomy && reference.IsDocumentCreatedByRivet()) { //if this is a top level aucent extension taxonomy and ... //if the skipAucentExtensions is set to true ... we want to load just the no rivet created files... //as we will merge the rivet created files later.... continue ; } if ( reference.ErrorList.Count > 0 ) { for ( int i = 0; i < reference.ErrorList.Count; i++ ) Common.WriteError( "XBRLParser.Error.Exception", validationErrors, SchemaFile + ": REFERENCE_ROLE Error: " + reference.ErrorList[i] ); } reference.Parse( out errors ); if ( errors > 0 ) { numErrors += errors; errorList.AddRange( reference.ErrorList ); numRefErrors += errors; } LinkbaseFileInfo refLinkbaseInfo = new LinkbaseFileInfo(); refLinkbaseInfo.LinkType = LinkbaseFileInfo.LinkbaseType.Reference; refLinkbaseInfo.Filename = refFile; refLinkbaseInfo.XSDFileName = schemaFile; this.linkbaseFileInfos.Add(refLinkbaseInfo); } if ( reference.ReferencesTable != null ) { IDictionaryEnumerator enumer = reference.ReferencesTable.GetEnumerator(); foreach( ReferenceLocator otherRL in reference.ReferencesTable.Values ) { if (referenceTable.Contains(otherRL.HRef)) { //TODO: add merge code similar to label locators int i = 0; ++i; ReferenceLocator rl = (ReferenceLocator)referenceTable[otherRL.HRef]; rl.Merge( otherRL ); } else { referenceTable[otherRL.HRef] = otherRL; } } } } } if ( !innerTaxonomy ) { //append the references to the root level referenceTable foreach ( Taxonomy t in dependantTaxonomies ) { if ( t.referenceTable != null && t.referenceTable.Count > 0 ) { errors = 0; // now append the references IDictionaryEnumerator enumer = t.referenceTable.GetEnumerator(); while ( enumer.MoveNext() ) { if ( referenceTable.ContainsKey( enumer.Key ) ) { ++numWarnings; Common.WriteWarning( "XBRLParser.Warning.DuplicateReference", errorList, enumer.Key.ToString() ); continue; } // otherwise, add it referenceTable[enumer.Key] = enumer.Value; } } } } }
private void MergeRoleRefsFromLinkbase( Hashtable linkbaseRoleRefs, string baseXsdFullFileName, string linkbaseFileFullName, LinkbaseFileInfo.LinkbaseType linkbaseType ) { if ( linkbaseRoleRefs != null ) { LinkbaseFileInfo fileInfo = new LinkbaseFileInfo(); fileInfo.Filename = linkbaseFileFullName; fileInfo.XSDFileName = baseXsdFullFileName; fileInfo.LinkType = linkbaseType; this.linkbaseFileInfos.Add(fileInfo); foreach ( DictionaryEntry de in linkbaseRoleRefs ) { string key = de.Key as string; fileInfo.RoleRefURIs.Add(key); RoleRef linkRR = de.Value as RoleRef; // add the file name reference linkRR.AddFileReference(Path.GetFileName(linkbaseFileFullName)); RoleRef rr; if ( this.roleRefs.TryGetValue( key, out rr ) ) { rr.MergeFileReferences( linkRR.GetFileReferences() ); } else { //update the href to be a full path (hash roleRef only has schema filename) //string newHref = GetHrefForRoleRef( linkRR, linkbaseSchema ); //linkRR.SetHref( newHref ); this.roleRefs.Add( key, linkRR ); } } } }
private void LoadLabels( out int numErrors ) { numErrors = 0; int errors = 0; if ( dependantTaxonomies.Count == 0 ) { int errs = LoadDependantTaxonomies(this.schemaPath); numErrors += errs; numLabelErrors += errs; } if ( labelFile == null ) { labelFile = GetLinkbaseReference( TARGET_LINKBASE_URI + LABEL_ROLE ); } if (tmplabelTable == null) { tmplabelTable = new Hashtable(); } if ( labelFile != null ) { //build the list of label files first.. //as if there are multiple files then we want to load //the extended label file first.... List<Label> labelsToLoad = new List<Label>(); foreach ( string labFile in labelFile ) { if ( labFile == null || labFile.Length == 0 ) continue; Label l = new Label(); l.OwnerHandle = OwnerHandle; l.loadingTaxonomy = this.GetLoadingTaxonomy(); l.PromptUser = this.PromptUser; l.Load(labFile, out numErrors); if (IsAucentExtension && skipAucentExtensions && !this.innerTaxonomy && l.IsDocumentCreatedByRivet()) { //if this is a top level aucent extension taxonomy and ... //if the skipAucentExtensions is set to true ... we want to load just the no rivet created files... //as we will merge the rivet created files later.... continue; } if ( l.ErrorList.Count > 0 ) { for ( int i = 0; i < l.ErrorList.Count; i++ ) Common.WriteError( "XBRLParser.Error.Exception", validationErrors, SchemaFile + ": LABEL_ROLE Error: " + l.ErrorList[i] ); } l.Parse( out errors ); this.MergeLanguagesAndLabelRoles( l.SupportedLanguages, l.LabelRoles ); if ( errors > 0 ) { numErrors += errors; errorList.AddRange( l.ErrorList ); numLabelErrors += errors; } //add the lable file info to the linkbasefileinfo LinkbaseFileInfo labLinkbaseInfo = new LinkbaseFileInfo(); labLinkbaseInfo.LinkType = LinkbaseFileInfo.LinkbaseType.Label; labLinkbaseInfo.Filename = labFile; labLinkbaseInfo.XSDFileName = schemaFile; this.linkbaseFileInfos.Add(labLinkbaseInfo); //TODO: Make sure we're not loading the same label file more than once if ( l.LabelTable != null ) { bool added = false; if (!innerTaxonomy && this.IsAucentExtension ) { //if this is the extended label file.... if (l.IsDocumentCreatedByRivet()) { labelsToLoad.Insert(0, l); added = true; } } if (!added) { labelsToLoad.Add(l); } } } foreach (Label l in labelsToLoad) { foreach (LabelLocator labelFileLL in l.LabelTable.Values) { if (tmplabelTable.Contains(labelFileLL.href)) { //element already exists in labelTable, so add new labelLocator to the existing value ArrayList labelErrors = new ArrayList(); LabelLocator ll = tmplabelTable[labelFileLL.href] as LabelLocator; ll.AddLabels(labelFileLL, labelErrors); } else { tmplabelTable[labelFileLL.href] = labelFileLL; } } } } if ( !innerTaxonomy ) { labelHrefHash = new Hashtable(); PopulateHrefHash(this.tmplabelTable); // and add the dependant taxonomy label files foreach ( Taxonomy t in dependantTaxonomies ) { PopulateHrefHash(t.tmplabelTable); //not sure what the merged label table is goin to be used for //but for now leaving it alone as don't want to create any new impact errors = 0; //merge the supported languages and roles.... this.MergeLanguagesAndLabelRoles( t.supportedLanguages, t.labelRoles ); } } }