public void TestUsGaap2008_ci_all() { //Trace.Listeners.Add( new TextWriterTraceListener(Console.Out) ); string fileName = @"S:\2009PublicReview\ind\ci\ssss.xsd"; Taxonomy s = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; if (s.Load(fileName, out errors) != true) { Assert.Fail((string)s.ErrorList[0]); } s.Parse(out errors); Assert.IsNotNull((s.allElements["dei_DocumentType"] as Element).EnumData, "enum data should not be null"); }
public void TestUkCompanies_Instances() { Taxonomy tax = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; if ( tax.Load( COMPANIES_HOUSE_FILE, out errors ) != true ) { Assert.Fail( (string)tax.ErrorList[0]); } errors = 0; // this loads up all dependant taxonomies, and loads the corresponding presentation, calculation, label, and reference linkbases // parse presentation first tax.CurrentLabelRole ="preferredLabel"; tax.CurrentLanguage = "en"; tax.Parse( out errors ); Assert.AreEqual( 0, errors, "should not have any errors"); Hashtable prefixXRef = new Hashtable(); prefixXRef["ae"] = "uk-gaap-ae"; prefixXRef["pt"] = "uk-gaap-pt"; prefixXRef["gc"] = "uk-gcd"; ValidateInstanceDoc( tax, DAMC_INST_FILE, 0,prefixXRef ); ValidateInstanceDoc( tax, DAMC_INST_FILE_Missing_Item, 2, prefixXRef); ValidateInstanceDoc( tax, DAM_INST_FILE, 0,prefixXRef ); ValidateInstanceDoc( tax, DAM_INST_FILE_Missing_Item, 1,prefixXRef ); }
public void TestSaveToLocalApplicationData() { string fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28.xsd"; if (File.Exists(fileName)) { File.Delete(fileName); } fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28.xsd"; if (File.Exists(fileName)) { File.Delete(fileName); } Taxonomy tx = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; Assert.AreEqual( true, tx.Load( "http://www.xbrl.org/us/fr/gaap/ci/2005-02-28/us-gaap-ci-2005-02-28.xsd", out errors ), "Could not load US GAAP File" ); Assert.AreEqual( 0, errors ); tx.Parse(out errors); DateTime end = DateTime.Now; Console.WriteLine( "Parse Time: {0}", end-start ); fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28.xsd"; Assert.IsTrue(File.Exists(fileName)); fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28.xsd"; Assert.IsTrue(File.Exists(fileName)); }
private void MutualFundTaxonomyLoad() { string fileName = @"Q:\Taxonomies\Fidelity.xsd"; DateTime start = DateTime.Now; Taxonomy tax = new Taxonomy(); tax.Load(fileName); int error; Assert.IsTrue(tax.Parse(out error)); tax.GetNodesByPresentation(true); List<DimensionNode> dNodes = new List<DimensionNode>(); Assert.IsTrue(tax.TryGetAllDimensionNodesForDisplay(null, null, true, out dNodes)); DateTime end = DateTime.Now; Console.WriteLine("Time taken = {0}", end - start); Element ele = tax.allElements["rr_MaximumAccountFeeOverAssets"] as Element; object notUsed = null; string errorStr; Assert.IsTrue( ele.TryValidateElement("0.62%", ref notUsed , out errorStr)); }
public void TestValidateTaxonomyRecursively() { Taxonomy tx = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; Assert.AreEqual( true, tx.Load( US_GAAP_FILE, out errors ), "Could not load US GAAP File" ); Assert.AreEqual( 0, errors ); Console.WriteLine("=========================="); ValidationStatus VS = tx.Validate(); Console.WriteLine("Number of Errros: " + tx.ValidationErrors.Count); Console.WriteLine("Number of Warnings: " + tx.ValidationWarnings.Count); Console.WriteLine("Validation Status: " + VS.ToString()); if (tx.ValidationWarnings.Count > 0) { System.Collections.IEnumerator vwarnings = tx.ValidationWarnings.GetEnumerator(); while ( vwarnings.MoveNext() ) Console.WriteLine(" Warning > " + vwarnings.Current); } if (tx.ValidationErrors.Count > 0) { System.Collections.IEnumerator verrors = tx.ValidationErrors.GetEnumerator(); while ( verrors.MoveNext() ) Console.WriteLine(" Error > " + verrors.Current); } Console.WriteLine("=========================="); }
public void TestLoadICI_RR_Taxonomy() { Taxonomy iciTaxonomy = new Taxonomy(); int numErrors = iciTaxonomy.Load(ICI_RR_SCHEMAFILE, false); Assert.AreEqual(0, numErrors, "Failed to load ICI-RR Taxonomy. " + numErrors + " errors were found"); Assert.IsTrue(iciTaxonomy.Parse(out numErrors), "Failed to parse the ICI-RR Taxonomy: " + numErrors + " errors were found"); }
public void Test_us_gaap_ci_stm_dis_all_2007_12_31() { string fileName = TestCommon.FolderRoot + @"USFRTF-2007-11-21-prerelease\ind\ci" + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-stm-dis-all-2007-12-31.xsd"; Taxonomy s = new Taxonomy(); int errors = 0; DateTime startLoad = DateTime.Now; DateTime startLoadParse = DateTime.Now; if (s.Load(fileName, out errors) != true) { Assert.Fail((string)s.ErrorList[0]); } DateTime endLoad = DateTime.Now; DateTime startParse = DateTime.Now; s.Parse(out errors); DateTime endParse = DateTime.Now; DateTime endLoadParse = DateTime.Now; s.CurrentLanguage = "en"; s.CurrentLabelRole = "preferredLabel"; long FileSize = new long(); DateTime startSerialize = DateTime.Now; Taxonomy.Serialize(s, @"C:\Aucent\TaxonomySerialized.bin", out FileSize); DateTime endSerialize = DateTime.Now; //Taxonomy sNew = new Taxonomy(); //DateTime startDeserialize = DateTime.Now; //Taxonomy.Deserialize(@"C:\Aucent\TaxonomySerialized.bin", out sNew); //DateTime endDeserialize = DateTime.Now; DateTime startGetNodes = DateTime.Now; ArrayList nodes = s.GetNodesByPresentation(true); DateTime endGetNodes = DateTime.Now; //ArrayList nodesNew = sNew.GetNodesByPresentation(true); //int count = 0; //int dimensionNodeCount = 0; //foreach (Node n in nodes) //{ // StringBuilder sb = DisplayNode(n, 0, ref count, ref dimensionNodeCount); // Console.WriteLine(sb.ToString()); //} //int countNew = 0; //int dimensionNodeCountNew = 0; //foreach (Node n in nodesNew) //{ // StringBuilder sb = DisplayNode(n, 0, ref countNew, ref dimensionNodeCountNew); // Console.WriteLine(sb.ToString()); //} Console.WriteLine("Time to Load: {0}", endLoad - startLoad); Console.WriteLine("Time to Parse: {0}", endParse - startParse); Console.WriteLine("Time to Load/Parse: {0}", endLoadParse - startLoadParse); Console.WriteLine("Time to Serialize: {0}", endSerialize - startSerialize); //Console.WriteLine("Time to Deserialize: {0}", endDeserialize - startDeserialize); Console.WriteLine("Time to GetNodes: {0}", endGetNodes - startGetNodes); Console.WriteLine("Serialized Filesize: {0}", FileSize); //Console.WriteLine("Count of elements in original presentation = {0}", count); //Console.WriteLine("Count of elements in deserialized presentation = {0}", countNew); }
private void AddDependantTaxonomy(string filename, string hintpath, string ns, ref int myErrors) { // compare against ourself if (string.Compare(filename, schemaFilename, true) == 0) { throw new AucentFatalException("XBRLParser.Error.RecursiveTaxonomies"); } string fileNameWithoutPath = Path.GetFileName(filename); int index = allFiles.BinarySearch(fileNameWithoutPath); if (index >= 0 || IsDependentTaxonomyLoaded(fileNameWithoutPath)) { Console.WriteLine("Taxonomy.GetDependantTaxonomies (" + schemaFile + "): Skip: " + fileNameWithoutPath); return; //nothing to add as the file is already loaded. } if (TaxonomyCacheManager != null) { Taxonomy depTax = TaxonomyCacheManager.GetTaxonomyByFileName(fileNameWithoutPath); if (depTax != null) { allFiles.Insert(~index, fileNameWithoutPath); //we found the dependant taxonomy in the cache .. we need to copy it to // make sure that we are not messing with the original Taxonomy copyToAdd = depTax.CopyTaxonomyForMerging(); if (copyToAdd.allFiles != null) { this.allFiles.AddRange(copyToAdd.allFiles); this.allFiles.Sort(); } dependantTaxonomies.Add(copyToAdd); dependantTaxonomyFilenames.Add(copyToAdd.schemaFilename); return; } } string fn = filename; string schemaFolder = schemaPath.Replace("\\", "/"); if (!schemaFolder.EndsWith("/")) { schemaFolder = schemaFolder + "/"; } if (hintpath != null) { hintpath = hintpath.Replace("\\", "/"); } //hint could be relative.. in which case we need to combine it with the //schema location of the taxonomy... if (hintpath == null || hintpath.Length == 0 || hintpath.StartsWith("..") || hintpath.StartsWith("/")) { if (hintpath != null && hintpath.Length > 0) { fn = schemaFolder + hintpath + "/" + filename; } else { fn = schemaFolder + filename; } } else if (hintpath != null ) { if (hintpath.EndsWith("/")) { fn = hintpath + filename; } else { fn = hintpath + "/" + filename; } } bool local = false; DateTime lastModified = DateTime.MinValue; bool URLExists; Dictionary<string, bool> filesAlreadyChecked = new Dictionary<string, bool>(); bool isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; if (!isValid && Directory.Exists(schemaFolder)) { fn = schemaFolder + "/" + filename; isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; if (!isValid) { fn = schemaFolder + hintpath + "/" + filename; isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } while (true ) { #region Check other locations if we cannot find the file in the location it is supposed to be in //check the following locations //ns + filename //hintpath + file name //parent location + hint path + filename //parent location + filename //current schema path + hint path + file name //current schema path + file name //ns + hint path + filename //just file name //isolated storage bool localPromptUser = false; if( !isValid) { //hintpath + file name fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(hintpath, filename); if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { //parent location + hint path + filename fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(schemaPath + hintpath, filename); if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { //parent location + filename fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(schemaPath, filename); if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { //ns + filename fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(ns, filename); if (!isValid && !filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { //current schema path + hint path + file name string path2 = string.Empty; if (local) path2 = schemaPath + Path.DirectorySeparatorChar + hintpath; else path2 = schemaPath + "/" + hintpath; fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(path2, filename); if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { //current path + filename try - fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(schemaPath, filename); if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { //ns + hint path + filename string path2 = string.Empty; if (local) path2 = ns + Path.DirectorySeparatorChar + hintpath; else path2 = ns + "/" + hintpath; fn = Aucent.MAX.AXE.Common.Utilities.AucentGeneral.AppendFileNameToSchemaPath(path2, filename); if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { fn = filename; if (!filesAlreadyChecked.ContainsKey(fn)) { isValid = ValidateFileExistance(fn, false, out local, out fn, out lastModified, out URLExists); filesAlreadyChecked[fn] = true; } } if (!isValid) { localPromptUser = true; // don't bother to test this one - we're done trying fn = filename; } Console.WriteLine("Taxonomy.GetDependantTaxonomies (" + schemaFile + "): Load: " + fn); #endregion Taxonomy t = new Taxonomy(true); t.PromptUser = this.PromptUser; t.OwnerHandle = OwnerHandle; //set the loading tax to the current tax or its loading tax object... t.loadingTaxonomy = GetLoadingTaxonomy(); // continue adding all files t.allFiles = allFiles; if (this.TopLevelTaxonomy != null) { t.TopLevelTaxonomy = this.TopLevelTaxonomy; } else { t.TopLevelTaxonomy = this; } try { if (t.Load(fn, localPromptUser && t.PromptUser ) != 0) { if (!localPromptUser) { //we found a valid file that does not exist.... //lets see if we can find a different file this time continue; } else { Common.WriteError("XBRLParser.Error.CantLoadFilename", errorList, fn, " to find the file"); ++myErrors; string errorMsg = null; if (errorList != null && errorList.Count > 0) { errorMsg = errorList[errorList.Count - 1] as string; if (errorMsg == null && errorList[errorList.Count - 1] is ParserMessage) { ParserMessage msg = errorList[errorList.Count - 1] as ParserMessage; if (msg != null) { errorMsg = msg.Message; } } } else { errorMsg = string.Format("Failed to load file {0}.", fn); } throw new AucentFatalException(errorMsg); } } } catch (XmlException xe) { Common.WriteError("XBRLParser.Error.CantLoadFilename", errorList, fn, xe.Message); ++myErrors; return; } if (BuildTaxonomyRelationship) { if (DirectDependantTaxonomies == null) DirectDependantTaxonomies = new List<string>(); if (!DirectDependantTaxonomies.Contains(fn)) { DirectDependantTaxonomies.Add(fn); } } allFiles.Insert(~index, fileNameWithoutPath); dependantTaxonomyFilenames.Add(fn); dependantTaxonomies.Add(t); int errors = t.LoadDependantTaxonomies(t.schemaPath); dependantTaxonomies.AddRange(t.dependantTaxonomies); dependantTaxonomyFilenames.AddRange(t.dependantTaxonomyFilenames); if (errors > 0) { errorList.Add(t.errorList); myErrors += errors; } break; } }
public void TestPerformSECValidations3() { Taxonomy tax = new Taxonomy(); tax.Load(@"S:\TESTSCHEMAS\EIX Taxonomy\eix.xsd"); int errors; Assert.IsTrue(tax.Parse(out errors), "Failed to parse taxonomy"); Dictionary<string, bool> eleDt = new Dictionary<string, bool>(); List<MarkupProperty> validMarkups = new List<MarkupProperty>(); List<ValidationErrorInfo> outParam = new List<ValidationErrorInfo>(); tax.PerformSECValidations(validMarkups, eleDt, null, false, ref outParam); outParam.Sort(); foreach (ValidationErrorInfo vei in outParam) { Console.WriteLine(vei.MyErrorString); } }
public void TestPerformSECValidations2() { Taxonomy tax = new Taxonomy(); tax.Load(@"S:\TESTSCHEMAS\BEN Taxonomy\ben-20091231.xsd"); int errors; Assert.IsTrue(tax.Parse(out errors), "Failed to parse taxonomy"); Instance ins = new Instance(); ArrayList errorsstr; Assert.IsTrue(ins.TryLoadInstanceDoc(@"S:\TESTSCHEMAS\BEN Taxonomy\ben-20091231.xml", out errorsstr)); Dictionary<string, bool> eleDt = new Dictionary<string,bool>(); List<MarkupProperty> validMarkups = new List<MarkupProperty>(); foreach (MarkupProperty mp in ins.markups) { mp.element = new Node( tax.allElements[mp.elementId] as Element); eleDt[mp.elementId] = true; validMarkups.Add(mp); } List<ValidationErrorInfo> outParam = new List<ValidationErrorInfo>(); tax.PerformSECValidations(validMarkups, eleDt, null, false, ref outParam); outParam.Sort(); foreach( ValidationErrorInfo vei in outParam ) { Console.WriteLine( vei.MyErrorString); } }
public void TestPerformSECValidations1() { Taxonomy tax = new Taxonomy(); tax.Load(@"S:\TESTSCHEMAS\FMC Taxonomy\fmc-20090930.xsd"); int errors; Assert.IsTrue(tax.Parse(out errors), "Failed to parse taxonomy"); Dictionary<string, bool> eleDt = new Dictionary<string,bool>(); eleDt.Add( "us-gaap_Revenues", true ); List<ValidationErrorInfo> outParam = new List<ValidationErrorInfo>(); tax.PerformSECValidations(null, eleDt, null, false, ref outParam); }
public void TestKoreanTaxonomy() { Taxonomy tax = new Taxonomy(); tax.Load(@"S:\TestSchemas\KoreanTest\xbrl03382-2008-04-23-ci.xsd"); int errors; Assert.IsTrue(tax.Parse(out errors), "Failed to parse taxonomy"); }
public void TestGetNodeByPath() { int numErrors; Taxonomy tax = new Taxonomy(); tax.Load(@"http://www.xbrl.org/us/fr/gaap/ci/2005-02-28/us-gaap-ci-2005-02-28.xsd"); tax.Parse(out numErrors); tax.currentLabelRole = "label"; tax.currentLanguage = "en"; ArrayList nodes = tax.GetNodesByPresentation(true); Node n = nodes[2] as Node; //Income Statement root node n = n.children[0] as Node; //Income & Expense abstarct node n = n.children[1] as Node; //Cost of Goods and Services Sold n = n.children[1] as Node; // Cost of Services Sold n = n.children[5] as Node; // Cost of Services - Total string path = n.GetPresentationPath(); Node testNode = tax.GetNodeFromPresentation(path, true); Assert.IsNotNull(testNode, "Failed to get node from presentation using path"); Assert.AreEqual(n, testNode, "Incorrect node returned by GetNodeFromPresentation"); }
public void TestCustomDataTypesLoading() { Taxonomy tax = new Taxonomy(); int numErrors; string pathToUse = @"S:\TESTSCHEMAS\TestTypesIn2011\sdds.xsd"; if (tax.Load(pathToUse, out numErrors)) { if (tax.Parse(out numErrors)) { foreach (KeyValuePair<string, string> kvp in tax.GetSimpleCustomElementTypes()) { Console.WriteLine("{0} - {1}", kvp.Key, kvp.Value); } } } }
public static bool TryLoadTaxonomy( string taxonomyPath, RequestCacheLevel remoteFileCachePolicy, //XmlCatalogResolver xmlCatalog, out Taxonomy currentTaxonomy, out int numberErrors, out string errorMsg) { errorMsg = string.Empty; currentTaxonomy = new Taxonomy(); currentTaxonomy.PromptUser = false; currentTaxonomy.CachePolicy = remoteFileCachePolicy; //currentTaxonomy.XmlCatalog = xmlCatalog; try { numberErrors = currentTaxonomy.Load(taxonomyPath, false); if (numberErrors == 0) { currentTaxonomy.Parse(out numberErrors); } } catch (XPathException) { numberErrors = 1; errorMsg = "Error parsing the taxonomy: Unable to find one or more of the dependent taxonomy files for taxonomy " + taxonomyPath; return false; } // ignore calc linkbase errors - don'care if (numberErrors != 0 && currentTaxonomy.ErrorList.Count > 0) { Console.WriteLine( " Pres Errors: " + currentTaxonomy.NumPresErrors ); Console.WriteLine( " Calc Errors: " + currentTaxonomy.NumCalcErrors ); Console.WriteLine( " Label Errors: " + currentTaxonomy.NumLabelErrors ); Console.WriteLine( " Reference Errors: " + currentTaxonomy.NumReferenceErrors ); currentTaxonomy.ErrorList.Sort(); try { foreach ( ParserMessage pm in currentTaxonomy.ErrorList ) { if ( pm.Level != TraceLevel.Error ) { break; // all the errors should be first after sort } errorMsg += pm.Message + Environment.NewLine; Console.WriteLine( pm.Level.ToString() + ": " + pm.Message ); } errorMsg = "Error parsing the taxonomy: "+ errorMsg.Trim(); } //Do nothing. Error wasn't written to the event log. catch { } // don't care about calc errors - if it's anything else, bomb out if ( numberErrors != currentTaxonomy.NumCalcErrors ) { return false; } } return true; }
/// <summary> /// Loads relevant information from this.<see cref="currentInstance"/> and retains auxiliary files from this.<see cref="currentReportDirectory"/>. /// </summary> private void BuildFilingSummary() { InstanceStatistics currentInstanceStat = InstanceUtils.GetStatisticsFromInstance( this.currentInstance ); this.currentFilingSummary.ReportFormat = this.ReportFormat; this.currentFilingSummary.Version = this.currentAssemblyVersion; //Deprecated - 2.4.0.2 //myFilingSummary.FilingDate = FilingDate; //myFilingSummary.PeriodEndDate = PeriodEnding; //myFilingSummary.TickerSymbol = TickerSymbol; //myFilingSummary.AccessionNumber = AccessionNumber; //myFilingSummary.FiscalYearEnd = FiscalYearEnd; //add the filing package files to the filing summary //OR copy the resource into the reports directory string instPath = Path.GetDirectoryName( this.currentInstancePath ); bool reportDirectoryExists = Directory.Exists( this.currentReportDirectory ); if( Directory.Exists( instPath ) ) { List<string> localTaxonomyFiles = new List<string>(); if( this.currentTaxonomy != null && this.currentTaxonomy.LinkbaseFileInfos != null ) { foreach( LinkbaseFileInfo linkInfo in currentTaxonomy.LinkbaseFileInfos ) { if( Path.IsPathRooted( linkInfo.Filename ) && File.Exists( linkInfo.Filename ) ) { string tmpName = Path.GetFileName( linkInfo.Filename ); localTaxonomyFiles.Add( tmpName.ToLower() ); } } } string prefix = Path.GetFileNameWithoutExtension( this.currentInstancePath ); string[] packageFiles = Directory.GetFiles( instPath ); foreach( string path in packageFiles ) { string ext = Path.GetExtension( path ).ToLower(); string file = Path.GetFileName( path ); switch( ext ) { case ".xsd": case ".xml": bool isInstance = false; if( !string.IsNullOrEmpty( this.currentInstancePath ) ) isInstance = this.currentInstancePath.EndsWith( file, StringComparison.CurrentCultureIgnoreCase ); bool isTaxonomy = false; if( !string.IsNullOrEmpty( this.currentTaxonomyPath ) ) isTaxonomy = this.currentTaxonomyPath.EndsWith( file, StringComparison.CurrentCultureIgnoreCase ); bool isTaxonomyReference = localTaxonomyFiles.Contains( file.ToLower() ); if( isInstance || isTaxonomy || isTaxonomyReference ) { //add the filing package files to the filing summary this.currentFilingSummary.InputFiles.Add( file ); } else { goto default; } break; default: if( reportDirectoryExists && FilingSummary.IsEdgarAttachmentFile( file ) ) { //copy the resource into the reports directory string copyTo = Path.Combine( this.currentReportDirectory, file ); FileUtilities.Copy( path, copyTo ); this.currentFilingSummary.SupplementalFiles.Add( file ); } break; } } } this.currentFilingSummary.SetStatistics( currentInstanceStat.NumberOfEntities, currentInstanceStat.NumberOfContexts, currentInstanceStat.NumberOfSegments, currentInstanceStat.NumberOfScenarios, currentInstanceStat.NumberOfUnitRefs, currentInstanceStat.NumberOfElements, currentInstanceStat.HasFootnotes, currentInstanceStat.HasTuples ); int errors = 0; ArrayList dependentTaxonomies = currentTaxonomy.GetDependantTaxonomies( false, out errors ); foreach( string taxonomyName in dependentTaxonomies ) { string name = Path.GetFileNameWithoutExtension( taxonomyName ); //check for old and new GAAP taxonomies //TODO: Exract method "IsIMBased" if( name.IndexOf( "gaap-ci" ) >= 0 || name.IndexOf( "gaap-im" ) >= 0 || name.IndexOf( "usfr-ime" ) >= 0 || name.IndexOf( "usfr-fste" ) >= 0 || name.IndexOf( "gaap-basi" ) >= 0 || name.IndexOf( "gaap-ins" ) >= 0 || name.IndexOf( "gaap-bd" ) >= 0 || name.IndexOf( "gaap-re" ) >= 0 || name.IndexOf( "usfr-ar" ) >= 0 || name.IndexOf( "usfr-mr" ) >= 0 || name.IndexOf( "usfr-seccert" ) >= 0 || name.IndexOf( "usfr-mda" ) >= 0 || name.IndexOf( "cistm" ) >= 0 || name.IndexOf( "mdastm" ) >= 0 || name.IndexOf( "mda-" ) >= 0 || name.IndexOf( "usgaap-" ) >= 0 ) { this.currentFilingSummary.BaseTaxonomies.Add( name ); if( this.currentFilingSummary.BaseTaxonomyFullPath == null ) this.currentFilingSummary.BaseTaxonomyFullPath = taxonomyName; } } this.currentFilingSummary.BaseTaxonomies.Sort(); if( this.currentFilingSummary.BaseTaxonomies.Count == 0 ) //need to go one more level down { foreach( string taxonomyFilePath in dependentTaxonomies ) { Taxonomy t1 = new Taxonomy(); t1.Load( taxonomyFilePath, false ); } } this.currentFilingSummary.HasCalculationLinkbase = currentTaxonomy.HasCalculation; this.currentFilingSummary.HasPresentationLinkbase = currentTaxonomy.HasPresentation; }
public void TestPerformSECValidations_TMP() { Taxonomy tax = new Taxonomy(); tax.Load(@"C:\Crossfire Stuff\us-gaap-2011-01-31\us-gaap-2011-01-31\ind\ci\testing.xsd"); int errors; Assert.IsTrue(tax.Parse(out errors), "Failed to parse taxonomy"); Dictionary<string, bool> eleDt = new Dictionary<string, bool>(); eleDt.Add("us-gaap_AccountsPayableAndAccruedLiabilities", true); eleDt.Add("us-gaap_AccountsPayable",true); List<ValidationErrorInfo> outParam = new List<ValidationErrorInfo>(); tax.PerformSECValidations(null, eleDt, null, false, ref outParam); }
private string CreateMergedTaxonomyFileNameFromInstanceDocumentMultiple(Instance instanceDoc, bool promptUser, string baseHref) { StringBuilder taxonomyNameSpace = new StringBuilder(); StringBuilder prefix = new StringBuilder(); StringBuilder importStatement = new StringBuilder(); string linkbaseStatement = instanceDoc.GetEmbeddedLinkbaseInfo(); foreach (string loc in instanceDoc.schemaRefs) { string location = ApplyBaseHRef(baseHref, loc); Taxonomy t = new Taxonomy(); if (t.Load(location, promptUser) > 0) return string.Empty; t.GetNSPrefix(); prefix.Append(t.nsPrefix); taxonomyNameSpace.Append(t.TargetNamespace); string href = ApplyBaseHRef(baseHref, t.schemaFile); //CEE 2009-05-28: Clean up the & within "W R Grace & Company" //Remove 1 level of encoding, and then reapply it. href = href.Replace( "&", "&" ).Replace( "&", "&" ); importStatement.Append(string.Format(@"<import namespace=""{0}"" schemaLocation=""{1}"" />", t.TargetNamespace, href ) ); importStatement.Append(Environment.NewLine); } string fileName = "Temp_" + DateTime.Now.Ticks.ToString() + "_Merged.xsd"; fileName = Path.Combine(System.Environment.CurrentDirectory, fileName); string taxonomyFileInfo = string.Format(Taxonomy.WrapperTaxonomyTemplate, taxonomyNameSpace.ToString(), prefix.ToString(), importStatement.ToString(), linkbaseStatement); StreamWriter sw = new StreamWriter(fileName, false); sw.Write(taxonomyFileInfo); sw.Close(); return fileName; }
public void TestRemoteFileInformationCache() { RemoteFiles.RemoteFileInformation.LoadRemoteFileInformation(); List<string> taxonomyListToLoad = new List<string>(); taxonomyListToLoad.Add(@"S:\TESTSCHEMAS\TaxonomyConversionTest1\etp-taxonomy.xsd"); taxonomyListToLoad.Add(@"S:\TESTSCHEMAS\TaxonomyConversionTest1\tmp\etp-taxonomy.xsd"); taxonomyListToLoad.Add("http://xbrl.sec.gov/rr/2010/rr-entire-2010-02-28.xsd"); //2009 taxonomyListToLoad.Add("http://taxonomies.xbrl.us/us-gaap/2009/ind/ci/us-gaap-ci-stm-dis-all-2009-01-31.xsd"); taxonomyListToLoad.Add("http://taxonomies.xbrl.us/us-gaap/2009/ind/basi/us-gaap-basi-stm-dis-all-2009-01-31.xsd"); taxonomyListToLoad.Add("http://taxonomies.xbrl.us/us-gaap/2009/ind/bd/us-gaap-bd-stm-dis-all-2009-01-31.xsd"); taxonomyListToLoad.Add("http://taxonomies.xbrl.us/us-gaap/2009/ind/ins/us-gaap-ins-stm-dis-all-2009-01-31.xsd"); taxonomyListToLoad.Add("http://taxonomies.xbrl.us/us-gaap/2009/ind/re/us-gaap-re-stm-dis-all-2009-01-31.xsd"); taxonomyListToLoad.Add("http://taxonomies.xbrl.us/us-gaap/2009/non-gaap/dei-ent-all-2009-01-31.xsd"); //2011 taxonomyListToLoad.Add("http://xbrl.fasb.org/us-gaap/2011/ind/ci/us-gaap-ci-stm-dis-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.fasb.org/us-gaap/2011/ind/basi/us-gaap-basi-stm-dis-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.fasb.org/us-gaap/2011/ind/bd/us-gaap-bd-stm-dis-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.fasb.org/us-gaap/2011/ind/ins/us-gaap-ins-stm-dis-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.fasb.org/us-gaap/2011/ind/re/us-gaap-re-stm-dis-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.sec.gov/dei/2011/dei-ent-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.sec.gov/invest/2011/invest-ent-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://xbrl.sec.gov/country/2011/country-ent-all-2011-01-31.xsd"); taxonomyListToLoad.Add("http://www.xbrl.org/lrr/role/negated-2009-12-16.xsd"); taxonomyListToLoad.Add("http://www.xbrl.org/lrr/role/net-2009-12-16.xsd"); foreach (string str in taxonomyListToLoad) { Taxonomy tax = new Taxonomy(); tax.Load(str); int error; Assert.IsTrue(tax.Parse(out error)); } }
public void TestLoadICI_RR_Taxonomy_WithPrompt() { Taxonomy iciTaxonomy = new Taxonomy(); int numErrors; Assert.IsTrue(iciTaxonomy.Load(ICI_RR_SCHEMAFILE, out numErrors), "Failed to load ICI-RR Taxonomy. " + numErrors + " errors were found"); Assert.IsTrue(iciTaxonomy.Parse(out numErrors), "Failed to parse the ICI-RR Taxonomy: " + numErrors + " errors were found"); }
public void Create2011URLMapping() { Taxonomy tax = new Taxonomy(); int numErrors; string pathToUse = "http://xbrl.fasb.org/us-gaap/2011/entire/us-gaap-entryPoint-all-2011-01-31.xsd"; if (tax.Load(pathToUse, out numErrors)) { if (tax.Parse(out numErrors)) { //get all the file URL mappings... Dictionary<string, string> fileUrlMap = tax.BuildTaxonomyUrlMappings(); RemoteFiles.UpdateTaxonomyURLMappingInfo(fileUrlMap); } } }
public void TestSaveToLocalApplicationData() { Taxonomy tx = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; // we only save to local app data if it's a web file location... Assert.AreEqual( true, tx.Load( US_GAAP_WEB_FILE, out errors ), "Could not load US GAAP File" ); Assert.AreEqual( 0, errors ); tx.Parse(out errors); DateTime end = DateTime.Now; Console.WriteLine( "Parse Time: {0}", end-start ); FileInfo fi = null; // Expecting 10 files to copy over... // 1. usfr-pte-2005-02-28.xsd fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-pte-2005-02-28.xsd" ); Assert.IsTrue(fi.Exists, "File not found: " + fi.Name); // 2. usfr-pte-2005-02-28-label.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-pte-2005-02-28-label.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 3. usfr-pte-2005-02-28-presentation.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-pte-2005-02-28-presentation.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 4. usfr-pte-2005-02-28-reference.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-pte-2005-02-28-reference.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 5. usfr-ptr-2005-02-28.xsd fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28.xsd" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 6. usfr-ptr-2005-02-28-calculation.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28-calculation.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 7. usfr-ptr-2005-02-28-presentation.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28-presentation.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 8. us-gaap-ci-2005-02-28.xsd fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28.xsd" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 9. us-gaap-ci-2005-02-28-calculation.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28-calculation.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); // 10. us-gaap-ci-2005-02-28-presentation.xml fi = new FileInfo( AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28-presentation.xml" ); Assert.IsTrue( fi.Exists, "File not found: " + fi.Name ); }
public void Dow_ParseUsingCloneOfBaseTaxonomy() { DateTime start = DateTime.Now; DOW_LoadAndParse(); DateTime end = DateTime.Now; Console.WriteLine("TIME TAKEN TO LOAD WITHOUT CACHE = {0}", end - start); string US_GAAP_FILE = TestCommon.FolderRoot + @"XBRL 2.1 Updated" +System.IO.Path.DirectorySeparatorChar +"2005-02-28" +System.IO.Path.DirectorySeparatorChar +"us-gaap-ci-2005-02-28.xsd"; Taxonomy bt = new Taxonomy(); bt.Load(US_GAAP_FILE); int errors = 0; bt.Parse(out errors); bt.CurrentLabelRole = "Label"; bt.CurrentLanguage = "en"; ArrayList nodeList = bt.GetNodesByPresentation(); MemoryStream msWrite = new MemoryStream(); BinaryFormatter formatterWrite = new BinaryFormatter(); formatterWrite.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple; formatterWrite.Serialize(msWrite, bt); byte[] bufOrig = msWrite.GetBuffer(); ArrayList flatListOrig = new ArrayList(); TestTaxonomy_US_GAAP_IM.GetFlatListOfPresentationNodes(nodeList, ref flatListOrig); Hashtable taxIdInfos = new Hashtable(); for (int i = 0; i < flatListOrig.Count; i++) { Node orig = flatListOrig[i] as Node; if( orig.MyElement != null ) { taxIdInfos[orig.Id] = orig.MyElement.TaxonomyInfoId; } } taxonomyCache[Path.GetFileName(US_GAAP_FILE)] = bt; Taxonomy.TaxonomyCacheManager = this; start = DateTime.Now; DOW_LoadAndParse(); end = DateTime.Now; Console.WriteLine("TIME TAKEN TO LOAD WITH CACHE = {0}", end - start); ArrayList nodeListAfter = bt.GetNodesByPresentation(); ArrayList flatListAfter = new ArrayList(); TestTaxonomy_US_GAAP_IM.GetFlatListOfPresentationNodes(nodeListAfter, ref flatListAfter); Assert.AreEqual(flatListOrig.Count, flatListAfter.Count, "should not change"); for (int i = 0; i < flatListAfter.Count; i++) { Node orig = flatListOrig[i] as Node; Node after = flatListAfter[i] as Node; Assert.AreEqual(orig.Label, after.Label, "Label should match"); Assert.AreEqual(orig.Id, after.Id); if (after.MyElement != null) { Assert.AreEqual(taxIdInfos[after.Id], after.MyElement.TaxonomyInfoId); } } Taxonomy.TaxonomyCacheManager = null; msWrite = new MemoryStream(); formatterWrite = new BinaryFormatter(); formatterWrite.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple; formatterWrite.Serialize(msWrite, bt); byte[] bufAfter = msWrite.GetBuffer(); Assert.AreEqual(bufOrig.Length, bufAfter.Length, "Cache object has changed"); MemoryStream msRead = new MemoryStream(bufOrig); BinaryFormatter formatterRead = new BinaryFormatter(); formatterRead.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple; Taxonomy origbt = formatterRead.Deserialize(msRead) as Taxonomy; Assert.AreEqual(origbt.AllElements.Count, bt.AllElements.Count); //for( int i = 0 ;i < bufAfter.Length ; i++ ) //{ // if (bufAfter[i] != bufOrig[i]) // { // Console.WriteLine("Position that is not correct = {0} out of total = {1}" ,i, bufAfter.Length); // } // Assert.AreEqual(bufAfter[i], bufOrig[i], "binary data is different"); //} }
public void TestCheckIsTextBlock() { //The original type is wrong, but the element name is right Element child1 = Element.CreateElement( DataTypeCode.String, "us-gaap_MortgageLoansOnRealEstateWriteDownOrReserveDisclosureTextBlock", true, PeriodType.duration ); child1.OrigElementType = "xbrli:stringItemType"; bool test1 = child1.IsTextBlock(); Assert.IsTrue( test1 ); //The original type is right child1 = Element.CreateElement( DataTypeCode.String, "child1", true, PeriodType.duration ); child1.OrigElementType = TEXT_BLOCK_ITEM_TYPE; bool test2 = child1.IsTextBlock(); Assert.IsTrue( test2 ); //Close, but not the same - should be false child1 = Element.CreateElement( DataTypeCode.String, "us-gaap_MortgageLoansOnRealEstateWriteDownOrReserveDisclosureTextBloc", true, PeriodType.duration ); child1.OrigElementType = "xbrli:stringItemType"; bool test3 = child1.IsTextBlock(); Assert.IsFalse( test3 ); //Not even close... child1 = Element.CreateElement( DataTypeCode.String, "us-gaap", true, PeriodType.duration ); child1.OrigElementType = "xbrli:positiveIntegerItemType"; bool test4 = child1.IsTextBlock(); Assert.IsFalse( test4 ); //Check a real element string fileName = "http://xbrl.us/us-gaap/1.0/ind/ci/us-gaap-ci-stm-2008-03-31.xsd"; int errors = 0; Taxonomy s = new Taxonomy(); if( s.Load( fileName, out errors ) != true ) { Assert.Fail( (string)s.ErrorList[ 0 ] ); } s.Parse( out errors ); Element child2 = s.allElements[ "us-gaap_MortgageLoansOnRealEstateWriteDownOrReserveDisclosureTextBlock" ] as Element; bool test5 = child2.IsTextBlock(); Assert.IsTrue( test5 ); child2 = s.allElements[ "us-gaap_AccountingChangesAndErrorCorrectionsTextBlock" ] as Element; bool test6 = child2.IsTextBlock(); Assert.IsTrue( test6 ); child2 = s.allElements["us-gaap_BankruptcyClaimsNumberClaimsFiled"] as Element; object parsed = new object(); string err; Assert.IsTrue(child2.TryValidateElement("1,000", ref parsed, out err), "Should be valid"); }
private void LoadRRTaxonomy() { string fileName = @"http://xbrl.sec.gov/rr/2010/rr-entire-2010-02-28.xsd"; DateTime start = DateTime.Now; Taxonomy tax = new Taxonomy(); tax.Load(fileName); int error; Assert.IsTrue(tax.Parse(out error)); }