Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with namespaces used in the value field of a segment explicit member #76

Closed
TheSly1 opened this issue Oct 25, 2022 · 3 comments
Closed
Assignees
Labels

Comments

@TheSly1
Copy link

TheSly1 commented Oct 25, 2022

If you use a segment value with a namespace which is not already used elsewhere (for example: dimension of some explicit member, fact, etc.), exception will be thrown.

string SchemaFilePath = "C:/Path/To/File.xsd";                                                                            
var instance = new Instance();                                                                                            
instance.SchemaReference = new SchemaReference("SCHEMA_TEST", SchemaFilepath);                                            
instance.TaxonomyVersion = "1.0";                                                                                         
                                                                                                                          
instance.SetDimensionNamespace("TEST1", "http://www.some-url.com/xbrl/TEST1");                                            
instance.AddDomainNamespace("TEST2", "http://www.some-url.com/xbrl/TEST2");                                               
instance.AddDomainNamespace("TEST3", "http://www.some-url.com/xbrl/TEST_FACT");                                           
                                                                                                                          
instance.Entity = new Entity("https://www.business-authority.org", "BusinessEntityID");                                   
instance.Period = new Period(DateTime.UtcNow);                                                                            
                                                                                                                          
var segment = new Segment();                                                                                              
segment.AddExplicitMember("TEST1:TestString", "TEST1:TestValue"); // Ok ("TEST1" is used in the same segment as dimension)
segment.AddExplicitMember("TEST1:TestTestString", "TEST2:Test"); // Exception ("TEST2" is not used anywhere else but here)
segment.AddExplicitMember("TEST1:Testx3String", "TEST3:MyTest"); // Ok ("TEST3" is used in the fact name)                 
                                                                                                                          
instance.AddFact(segment, "TEST3:FactTest", "", "2", "12345");                                                            
                                                                                                                          
instance.ToFile("text.xml"); // Exception is thrown here 
@dgm9704
Copy link
Owner

dgm9704 commented Oct 25, 2022

Thanks! I'll check it out.

@TheSly1
Copy link
Author

TheSly1 commented Oct 25, 2022

I managed to find the solution for myself.
Here it is if it helps you:

In file: Instance.cs
Function: GetXmlSerializerNamespaces
Faulty code was this:

Contexts.
      Where(c => c.Entity.Segment != null).
      Select(c => c.Entity.Segment).
      SelectMany(s => s.ExplicitMembers).
      Select(m => m.Dimension.Namespace).
      ToList().ForEach(ns => namespaces.Add(ns));

Mine version:

Contexts.
        Where(c => c.Entity.Segment != null).
        Select(c => c.Entity.Segment).
        SelectMany(s => s.ExplicitMembers).
        Select(m => new { dimensionNamespace = m.Dimension.Namespace, valueNamespace = m.Value.Namespace }).
        ToList().
        ForEach(obj =>
        {
	        if (!string.IsNullOrEmpty(obj.dimensionNamespace))
	        {
		        namespaces.Add(obj.dimensionNamespace);
	        }
        
	        if (!string.IsNullOrEmpty(obj.valueNamespace))
	        {
		        namespaces.Add(obj.valueNamespace);
	        }
        });

Hope it helps :)

dgm9704 pushed a commit that referenced this issue Oct 26, 2022
@dgm9704 dgm9704 self-assigned this Oct 26, 2022
@dgm9704 dgm9704 added the bug label Oct 26, 2022
dgm9704 pushed a commit that referenced this issue Oct 27, 2022
and default namespace xbrldi when segments are used
@dgm9704
Copy link
Owner

dgm9704 commented Oct 27, 2022

Thank you, there is now version 1.2.2 (+corresponding nuget) with a fix for this + fix for outputting xbrldi namespace when using segments.

@dgm9704 dgm9704 closed this as completed Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants