Skip to content

Commit

Permalink
Add taxonomy names in other languages. Option to use only reports fro…
Browse files Browse the repository at this point in the history
…m Jan1 to Dec31
  • Loading branch information
Barry Coughlan committed Feb 12, 2013
1 parent 20a1e92 commit 5090ca0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
15 changes: 12 additions & 3 deletions rdfconverters/xbrl2rdf/schemas/xebr2xbrl.n3
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
@prefix xbrl_es_cnmv: <http://www.dfki.de/lt/xbrl_es_cnmv.owl#> .

xbrl_be: a xebr:LocalTaxonomy;
skos:prefLabel "Belgium PFS"@en .
skos:prefLabel "Belgium PFS"@en ;
skos:prefLabel "België PFS"@nl ;
skos:prefLabel "Belgien PFS"@de ;
skos:prefLabel "Bélgica PFS"@es .
xbrl_es: a xebr:LocalTaxonomy;
skos:prefLabel "Spain PGC"@en .
skos:prefLabel "Spain PGC"@en ;
skos:prefLabel "Spanje PGC"@nl ;
skos:prefLabel "Spanien PGC"@de ;
skos:prefLabel "España PGC"@es .
xbrl_es_cnmv: a xebr:LocalTaxonomy;
skos:prefLabel "Spain IPP-GEN"@en .
skos:prefLabel "Spain IPP-GEN"@en ;
skos:prefLabel "Spanje IPP-GEN"@nl ;
skos:prefLabel "Spanien IPP-GEN"@de ;
skos:prefLabel "España IPP-GEN"@es .

xbrl_es_cnmv:es-be-fs_CapitalFondoDotacion a owl:DatatypeProperty;
skos:altLabel "Patrimonio neto fondos propios capital"@es;
Expand Down
13 changes: 8 additions & 5 deletions rdfconverters/xbrl2rdf/xbrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ class XBRLReport:
should be True for 2010 and False for 2011.
"""

def __init__(self, xmltree, source_taxonomy):
def __init__(self, xmltree, source_taxonomy, only_year_boundaries=False):
self.source_taxonomy = source_taxonomy
self.root = xmltree.getroot()
self.ns = self.root.nsmap

self.filings = None

self.units = self.__extract_units()
self.contexts = self.__extract_contexts()
self.contexts = self.__extract_contexts(only_year_boundaries)
self.items = self.__extract_financial_items()

self.x2x = XBRL2XEBR(source_taxonomy)
Expand Down Expand Up @@ -101,21 +101,24 @@ def parse_filings(self):
def get_filings_list(self):
return self.filings

def __extract_contexts(self):
def __extract_contexts(self, only_year_boundaries):
'''
Returns a dictionary of XBRL contexts with the context id attribute as a key and
either instant or start/end dates.
'''
contexts = {}
for context in self.root.findall("./{http://www.xbrl.org/2003/instance}context", namespaces=self.ns):
c = contexts[context.attrib['id']] = {}
c = {}

instant = context.find('.//{http://www.xbrl.org/2003/instance}instant', namespaces=self.ns)
if instant is not None:
c['instant'] = instant.text
else:
c['start'] = context.find('.//{http://www.xbrl.org/2003/instance}startDate', namespaces=self.ns).text
c['end'] = context.find('.//{http://www.xbrl.org/2003/instance}endDate', namespaces=self.ns).text

if (not only_year_boundaries) or c.get('instant','').endswith("12-31") or (c.get('start','').endswith("01-01") and c.get('end','').endswith("12-31")):
contexts[context.attrib['id']] = c

return contexts

Expand Down Expand Up @@ -307,7 +310,7 @@ def __str__(self):
class XBRLSpainCNMV(XBRLReport):

def __init__(self, xmltree):
super().__init__(xmltree, "http://www.dfki.de/lt/xbrl_es_cnmv.owl#")
super().__init__(xmltree, "http://www.dfki.de/lt/xbrl_es_cnmv.owl#", only_year_boundaries=True)

def get_identifier(self):
id_expression = ".//dgi-est-gen:IdentifierCode/dgi-est-gen:IdentifierValue"
Expand Down

0 comments on commit 5090ca0

Please sign in to comment.