xbrlus / xule

An open-source XBRL processor for business rules, rendering and custom data reporting. See https://xbrl.us/xule for documentation and https://xbrl.us/xule-editor for a VS Code syntax highlighter.
Apache License 2.0
24 stars 9 forks source link

Inconsistent `.role-description` value when getting taxonomy using `taxonomy(...)` #8

Closed selgamal closed 2 years ago

selgamal commented 2 years ago

Edited

This may be a trival issue or I am doing something wrong, I am not getting the correct value for property networks().role-description (or role.description) if a taxonomy is loaded using taxonomy(<taxonomy_url>).

I am trying to use XULE to compare 2 taxonomies, I am loading a taxonomy using arelleCmdLine -f <loaded_taxonoy_url> and then the XULE rule gets the other taxonomy for comparison using taxonomy(<other_taxonomy_url>). It appears that when trying to get the value of property networks().role-description (or role.description) for a specific role uri form both taxonomies, the result is always returned from the taxonomy that was loaded first.

To demonstrate, consider ESEF taxonomy 2021 which has a new role http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o, this role does not exist in ESEF taxonomy 2019, if I load ESEF taxonomy 2019 first using:

arelleCmdLine -f http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd ...

Then try to get the role-description property based on ESEF 2021 loaded later in the rule using taxonomy(...) , I get a none value while there should be a description for this role in ESEF 2021 taxonomy, this is the rule I am using:

output 
list(taxonomy("http://www.esma.europa.eu/taxonomy/2021-03-24/esef_all.xsd")
        .networks(none, "http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o")
        .role-description) /* This returns None, while should return [836600o] Notes - Insurance contracts (IFRS 17) */

Load ESEF 2019 first and run above rule using:

$ arelleCmdLine --plugins xule -f http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd --internetRecheck never --xule-run --xule-compile link-role-test.xule --xule-rule-set link-role-test.xule.zip --logFormat "%(message)s"

The expected result is [836600o] Notes - Insurance contracts (IFRS 17) but the result I am getting:

set(None)

Now if I load ESEF 2021 first and run the same exact rule using:

$ arelleCmdLine --plugins xule -f http://www.esma.europa.eu/taxonomy/2021-03-24/esef_all.xsd --internetRecheck never --xule-run --xule-compile link-role-test.xule --xule-rule-set link-role-test.xule.zip --logFormat "%(message)s"

We get the correct result Result:

set([836600o] Notes - Insurance contracts (IFRS 17))

If I am not mistaken the results for calling role-description should be consistent no matter which taxonomy gets loaded first, unless I am missing something...

campbellpryde commented 2 years ago

Your code is correct. There seems to be an issue with the underlying data model of Arelle, which seems to be dropping the used-on and description attributes of this and a few other roles in certain circumstances. We are looking into the issue and hope to resolve asap.

Campbell Pryde

President and CEO

XBRL US Inc.

@. @.>*

https://xbrl.us https://xbrl.us

[image: XBRL US]

The non-profit community https://xbrl.us/xusmembers improving U.S. reporting through a free, open standard https://xbrl.us/home/learn/free-open-standards/.

On Sat, Aug 6, 2022 at 10:59 PM Sherif ElGamal @.***> wrote:

This may be a trival issue or I am doing something wrong, I am not getting the correct value for property networks().role-description (or role.description) if a taxonomy is called using taxonomy().

Just for experimenting with XULE, I am trying to compare 2 taxonomies, ESEF taxonomy 2019 and ESEF taxonomy 2021, I am loading ESEF taxonomy 2019 using arelleCmdLine -f http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd ... and then getting ESEF Taxonomy 2021 in the rule using constant $other_taxonomy = taxonomy(' http://www.esma.europa.eu/taxonomy/2021-03-24/esef_all.xsd')

ESEF 2021 has role http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o which does not exist in esef 2019, when trying to get the description / definition of this role I am expecting to get null / nothing from ESEF 2019 taxonomy and get a text value from ESEF 2021 taxonomy (role definition), my rule is as follows (the query below is just to isolate this issue):

constant $loaded_taxonomy = taxonomy()constant $other_taxonomy = taxonomy('http://www.esma.europa.eu/taxonomy/2021-03-24/esef_all.xsd') / esef 2021/ / Get the networks to be able to access role-description and role-uri /constant $loaded_taxonomy_networks = $loaded_taxonomy.networks(none, "http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o")constant $other_taxonomy_networks = $other_taxonomy.networks(none, "http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o") output-attribute tagoutput role-uri-and-description / just output description and role uri/for $t in list( list("ESEF 2019 (expecting NONE for label & uri)", $loaded_taxonomy_networks.role-description, $loaded_taxonomy_networks.role-uri), list("ESEF 2021 (expecting VALUE for label & uri)", $other_taxonomy_networks.role-description, $other_taxonomy_networks.role-uri) ) $t message"{$rule-value[1]} ==> {$rule-value[2]} | {$rule-value[3]}" tag"role-test"

Load ESEF 2019 and run above rule using::

$ arelleCmdLine --plugins xule -f http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd --internetRecheck never --xule-run --xule-compile link-role-test.xule --xule-rule-set link-role-test.xule.zip --logFormat "%(message)s"

Resutls:

ESEF 2019 (expecting NONE for label & uri) ==> set() | set() # OK ESEF 2021 (expecting VALUE for label & uri) ==> set(None) | set(http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o) ##> NOT OK no label

Now flip around load ESEF 2021 via arelle (the one that has the mentioned link role) and get esef 2019 using taxonomy(...) (the one without the role):

constant $loaded_taxonomy = taxonomy()constant $other_taxonomy = taxonomy('http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd') / esef 2019 / / Get the networks to be able to access role-description and role-uri /constant $loaded_taxonomy_networks = $loaded_taxonomy.networks(none, "http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o")constant $other_taxonomy_networks = $other_taxonomy.networks(none, "http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o") output-attribute tagoutput role-uri-and-description / just output description and role uri/for $t in list( list("ESEF 2021 (expecting VALUE for label & uri)", $loaded_taxonomy_networks.role-description, $loaded_taxonomy_networks.role-uri), list("ESEF 2019 (expecting NONE for label & uri)", $other_taxonomy_networks.role-description, $other_taxonomy_networks.role-uri) ) $t message"{$rule-value[1]} ==> {$rule-value[2]} | {$rule-value[3]}" tag"role-test"

Load ESEF 2021 and run above rule using:

$ arelleCmdLine --plugins xule -f http://www.esma.europa.eu/taxonomy/2021-03-24/esef_all.xsd --internetRecheck never --xule-run --xule-compile link-role-test.xule --xule-rule-set link-role-test.xule.zip --logFormat "%(message)s"

Result:

ESEF 2021 (expecting VALUE for label & uri) ==> set([836600o] Notes - Insurance contracts (IFRS 17)) | set(http://www.esma.europa.eu/xbrl/role/all/ifrs_17_role-836600o) # OK ESEF 2019 (expecting NONE for label & uri) ==> set() | set() # OK

— Reply to this email directly, view it on GitHub https://github.com/xbrlus/xule/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADC2RF254B76ZDRIAT4SDRDVXZAQNANCNFSM55YM4KIQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

campbellpryde commented 2 years ago

Your code is correct. There seems to be an issue with the underlying data model of Arelle, which seems to be dropping the used-on and description attributes of this and a few other roles in certain circumstances. We are looking into the issue and hope to resolve asap.

campbellpryde commented 2 years ago

Upon further investigation this seems o be an issue if two taxonomies are being used. The description from the open taxonomy seems to be used for the description of the second taxonomy where the uri is the same. In this case the 2019 description and URI used on is none and this is reported for 2021.

selgamal commented 2 years ago

Upon further investigation this seems o be an issue if two taxonomies are being used. The description from the open taxonomy seems to be used for the description of the second taxonomy where the uri is the same. In this case the 2019 description and URI used on is none and this is reported for 2021.

Yes that is the case, I just couldn't pin down which part of the code was responsible for this, but I think I found it, I added a draft pr to explain what I think is happening with a quick fix.

campbellpryde commented 2 years ago

We have updated the original pull request.

selgamal commented 2 years ago

Yes 4589881919036a16907417887f31d26c3dfb391c looks much better then what I sent!

A last question, is there a function similar to xbrl formula xfi:linkbase-link-roles?

campbellpryde commented 2 years ago

You would do the following if you wanted a set of parent child link roles: taxonomy().networks(parent-child) or for a specific taxonomy: taxonomy('http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd').networks(parent-child)

campbellpryde commented 2 years ago

If you wanted the descriptions of the parent-child arcroles for the 2019 esef you could do the following:

$esef = taxonomy('http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd'); filter $esef.networks(parent-child) returns $item.role.description

selgamal commented 2 years ago

If you wanted the descriptions of the parent-child arcroles for the 2019 esef you could do the following:

$esef = taxonomy('http://www.esma.europa.eu/taxonomy/2019-03-27/esef_all.xsd'); filter $esef.networks(parent-child) returns $item.role.description

The filter...where is very useful, exactly what I was looking for. Thank you again!