Skip to content

Commit

Permalink
Generate de-gaap-ci (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
quambene authored Jul 30, 2024
1 parent a828480 commit f46f84d
Show file tree
Hide file tree
Showing 133 changed files with 380,356 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ validation_response.xml
server_response.xml
*.pdf

# schema
schema/*

# csv
.~lock.**.csv#

Expand Down
49 changes: 49 additions & 0 deletions taxel-py/src/xsd_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,52 @@ def test_generate_xml_ebilanz_gcd():
expected_xml = file.read()

assert actual_xml.decode("UTF-8") == expected_xml


@pytest.mark.unit
def test_validate_xml_ebilanz_gaap_ci():
schema_path = '../test_data/schema/ebilanz/ebilanz_000002.xsd'
output_path = "../test_data/taxonomy/v6.6/de-gaap-ci/output.xml"

schema = XMLSchema10(schema_path, loglevel=20, validation='strict')
xml = load_xml(output_path)
validate_xml(schema, xml)


@pytest.mark.unit
def test_generate_xml_ebilanz_gaap_ci():
schema_path = '../test_data/schema/ebilanz/ebilanz_000002.xsd'
input_path = "../test_data/taxonomy/v6.6/de-gaap-ci/input.json"
output_path = "../test_data/taxonomy/v6.6/de-gaap-ci/output.xml"
target_namespace = "ebilanz"
namespaces = {
"xs": "http://www.w3.org/2001/XMLSchema",
"xsi": "http://www.w3.org/2001/XMLSchema-instance",
"xlink": "http://www.w3.org/1999/xlink",
"xhtml": "http://www.w3.org/1999/xhtml",
"xbrli": "http://www.xbrl.org/2003/instance",
"xbrldt": "http://xbrl.org/2005/xbrldt",
"xbrldi": "http://xbrl.org/2006/xbrldi",
"link": "http://www.xbrl.org/2003/linkbase",
"iso4217": "http://www.xbrl.org/2003/iso4217",
"hgbref": "http://www.xbrl.de/taxonomies/de-ref-2010-02-19",
"de-hgbrole": "http://www.xbrl.de/taxonomies/hgbrole-2022-05-02",
# taxonomy v6.6 for Global Common Document (GCD)
"gcd-shell": "http://www.xbrl.de/taxonomies/de-gcd-2022-05-02/shell",
"de-gcd": "http://www.xbrl.de/taxonomies/de-gcd-2022-05-02",
# taxonomy v6.6 for Generally Accepted Accounting Principles (GAAP)
"gaap-shell-microbilg": "http://www.xbrl.de/taxonomies/de-gaap-ci-2022-05-02/shell-microbilg",
"de-gaap-ci": "http://www.xbrl.de/taxonomies/de-gaap-ci-2022-05-02"
}

schema = XMLSchema10(schema_path, loglevel=20, validation='strict')

data = load_data(input_path)
xml = generate_xml(schema, data, target_namespace, namespaces)
root = xml.getroot()
actual_xml = ET.tostring(root, encoding="UTF-8", xml_declaration=True)

with open(output_path, 'r', encoding="UTF-8") as file:
expected_xml = file.read()

assert actual_xml.decode("UTF-8") == expected_xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--(c) XBRL Deutschland e.V. - see http://www.xbrl.de-->


<linkbase xmlns="http://www.xbrl.org/2003/linkbase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd">
<roleRef xmlns:xlink="http://www.w3.org/1999/xlink"
roleURI="http://www.xbrl.de/taxonomies/de-gaap-ci/role/adjustmentOfIncome"
xlink:href="de-gaap-ci-2022-05-02.xsd#role_adjustmentOfIncome"
xlink:type="simple"/>
<calculationLink xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:role="http://www.xbrl.de/taxonomies/de-gaap-ci/role/adjustmentOfIncome"
xlink:type="extended">
<loc xlink:type="locator" xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl"
xlink:label="de-gaap-ci_tpl"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl.receivTrade"
xlink:label="de-gaap-ci_tpl.receivTrade"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl.receivOther"
xlink:label="de-gaap-ci_tpl.receivOther"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl.inventory"
xlink:label="de-gaap-ci_tpl.inventory"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl.liabTrade"
xlink:label="de-gaap-ci_tpl.liabTrade"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl.otherAdditions"
xlink:label="de-gaap-ci_tpl.otherAdditions"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_tpl.otherDeductions"
xlink:label="de-gaap-ci_tpl.otherDeductions"/>
<calculationArc xlink:from="de-gaap-ci_tpl" xlink:to="de-gaap-ci_tpl.receivTrade" order="2"
weight="1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
<calculationArc xlink:from="de-gaap-ci_tpl" xlink:to="de-gaap-ci_tpl.receivOther" order="3"
weight="1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
<calculationArc xlink:from="de-gaap-ci_tpl" xlink:to="de-gaap-ci_tpl.inventory" priority="0"
weight="1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
<calculationArc xlink:from="de-gaap-ci_tpl" xlink:to="de-gaap-ci_tpl.liabTrade" order="4"
weight="-1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
<calculationArc xlink:from="de-gaap-ci_tpl" xlink:to="de-gaap-ci_tpl.otherAdditions" order="5"
weight="1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
<calculationArc xlink:from="de-gaap-ci_tpl" xlink:to="de-gaap-ci_tpl.otherDeductions" order="6"
weight="-1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
</calculationLink>
</linkbase>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--(c) XBRL Deutschland e.V. - see http://www.xbrl.de-->


<linkbase xmlns="http://www.xbrl.org/2003/linkbase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd">
<roleRef xmlns:xlink="http://www.w3.org/1999/xlink"
roleURI="http://www.xbrl.de/taxonomies/de-gaap-ci/role/appropriationProfits"
xlink:href="de-gaap-ci-2022-05-02.xsd#role_appropriationProfits"
xlink:type="simple"/>
<calculationLink xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:role="http://www.xbrl.de/taxonomies/de-gaap-ci/role/appropriationProfits"
xlink:type="extended">
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_incomeUse.gainLoss"
xlink:label="de-gaap-ci_incomeUse.gainLoss"/>
<loc xlink:type="locator"
xlink:href="de-gaap-ci-2022-05-02.xsd#de-gaap-ci_incomeUse.gainLoss.releaseDiffFromCapitalConsol"
xlink:label="de-gaap-ci_incomeUse.gainLoss.releaseDiffFromCapitalConsol"/>
<calculationArc xlink:from="de-gaap-ci_incomeUse.gainLoss"
xlink:to="de-gaap-ci_incomeUse.gainLoss.releaseDiffFromCapitalConsol"
order="7"
weight="1"
xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item"
xlink:type="arc"/>
</calculationLink>
</linkbase>
Loading

0 comments on commit f46f84d

Please sign in to comment.