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

[Question] how to add an explicit member with namespace specified #70

Closed
ma3yta opened this issue Aug 31, 2020 · 5 comments
Closed

[Question] how to add an explicit member with namespace specified #70

ma3yta opened this issue Aug 31, 2020 · 5 comments
Assignees

Comments

@ma3yta
Copy link
Contributor

ma3yta commented Aug 31, 2020

My Code:

var instance = new Instance();
instance.CheckExplicitMemberDomainExists = true;
instance.AddDomainNamespace("h04", "http://sbr.gov.au/dims/RprtPyType.02.00.dims");
var entity = new Entity("http://www.ato.gov.au/abn", "18641935846");
entity.AddExplicitMember("h04:ReportPartyTypeDimension", "ReportingParty");

var ctx = new Diwen.Xbrl.Context
{
   Entity = entity,
   Id = "C001"
};

instance.Contexts.Add(ctx);
            
try
{
  var xml = instance.ToXml();
  Console.WriteLine(xml);
}
catch (Exception ex)
{
  Console.WriteLine(ex);
}

Actual Result:
<xbrldi:explicitMember dimension=":ReportPartyTypeDimension">ReportingParty</xbrldi:explicitMember>

<?xml version="1.0" encoding="UTF-8"?>
<?instance-generator id="Diwen.Xbrl" version="1.0.4.0" creationdate="2020-08-31T17:47:05:26+07:00"?>
<xbrli:xbrl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance">
	<link:schemaRef/>
	<xbrli:context id="C001">
		<xbrli:entity>
			<xbrli:identifier scheme="http://www.ato.gov.au/abn">18641935846</xbrli:identifier>
			<xbrli:segment>
				<xbrldi:explicitMember dimension=":ReportPartyTypeDimension">ReportingParty</xbrldi:explicitMember>
			</xbrli:segment>
		</xbrli:entity>
		<xbrli:period/>
	</xbrli:context>
</xbrli:xbrl>

Expected Result:

<xbrldi:explicitMember dimension="h04:ReportPartyTypeDimension">h04:ReportingParty</xbrldi:explicitMember>

<?xml version="1.0" encoding="UTF-8"?>
<?instance-generator id="Diwen.Xbrl" version="1.0.4.0" creationdate="2020-08-31T17:47:05:26+07:00"?>
<xbrli:xbrl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance">
	<link:schemaRef/>
	<xbrli:context id="C001">
		<xbrli:entity>
			<xbrli:identifier scheme="http://www.ato.gov.au/abn">18641935846</xbrli:identifier>
			<xbrli:segment>
				<xbrldi:explicitMember dimension="h04:ReportPartyTypeDimension">h04:ReportingParty</xbrldi:explicitMember>
			</xbrli:segment>
		</xbrli:entity>
		<xbrli:period/>
	</xbrli:context>
</xbrli:xbrl>
@dgm9704
Copy link
Owner

dgm9704 commented Aug 31, 2020

Hi,
I will take a look and get back to you.

@dgm9704 dgm9704 self-assigned this Aug 31, 2020
@dgm9704
Copy link
Owner

dgm9704 commented Aug 31, 2020

I'm just back from vacation and my brain isn't yet in full XBRL mode so this might take some time :(
Meanwhile if you already haven't done so, you could maybe take a look at the sample code in
SBRInstanceTests.cs
and see if that gives some ideas?

@ma3yta
Copy link
Contributor Author

ma3yta commented Aug 31, 2020

@dgm9704 resolved. thanks

var entity = new Entity("http://www.ato.gov.au/abn", "18641935846");
            instance.SetDimensionNamespace("h04", "http://sbr.gov.au/dims/RprtPyType.02.00.dims");
            var segment = new Segment(instance);
            segment.AddExplicitMember("ReportPartyTypeDimension", "h04:ReportingParty");
            entity.Segment = segment;

@ma3yta ma3yta closed this as completed Aug 31, 2020
@dgm9704
Copy link
Owner

dgm9704 commented Aug 31, 2020

Yes, I think the problem is that because my code is a bit stupid,
the instance reference needs to be set before adding the member,
otherwise the member doesn't have access to the namespaces, and they don't get set afterwards.
This is not intuitive behaviour and it isn't mentioned anywhere.
I apologize for this and will try to either fix this in the future, or at least make
it obvious that things need to be done in a certain order (which is always bad imho)
I am glad that you got it working though, nice job!

@ma3yta
Copy link
Contributor Author

ma3yta commented Aug 31, 2020

thank you for making this repo public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants