python-xbrl 模块给出错误信息:"The xbrl file is empty!"

python-xbrl module gives error message: "The xbrl file is empty!"

我是 Python 和编程语言的新手,我尝试使用 python-xbrl 模块解析 XBRL 文件。

我正在按照此模块 (https://pypi.python.org/pypi/python-xbrl) 的说明解析 .xml 个文件

但是一些 .xml 文件给出了这个错误信息:

The xbrl file is empty!

以下是我的Python代码,HelloWorld.xml没有给出错误信息而Novartis-2002-11-15.xml有。


from xbrl import XBRLParser, GAAP, GAAPSerializer

xbrl_parser = XBRLParser()

xbrl1 = xbrl_parser.parse(open("HelloWorld.xml"))

print(xbrl1)

xbrl2 = xbrl_parser.parse(open("Novartis-2002-11-15.xml"))

print(xbrl2)

Novartis-2002-11-15.xml 下载自 https://www.xbrl.org/taxonomy/int/fr/ias/ci/pfs/2002-11-15/samples.htm

你有什么想法吗? 任何评论将不胜感激。

文档 Novartis-2002-11-15.xml 包含一个对应于旧版(public 工作草案)XBRL 的实例。特别是,此文件中的根元素是已弃用的 group 元素。 python-xbrl 发现它是空的,因为它需要根 xbrl 元素,如最新的 XBRL 2.1 recommendation.

中所指定
<group 
   xmlns='http://www.xbrl.org/2001/instance'
   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
   xmlns:iso4217='http://www.xbrlSolutions.com/taxonomies/iso4217/2002-06-30'
   xmlns:iascf-pfs='http://www.xbrl.org/taxonomy/int/fr/ias/ci/pfs/2002-11-15'
   xmlns:novartis='http://www.xbrl.org/taxonomy/int/fr/ias/pfs/2002-11-15/Novartis-2002-11-15'
   xsi:schemaLocation='
             http://www.xbrlSolutions.com/taxonomies/iso4217/2002-06-30 http://www.xbrlSolutions.com/taxonomies/iso4217/2002-06-30/iso4217.xsd 
             http://www.xbrl.org/taxonomy/int/fr/ias/ci/pfs/2002-11-15 ias-ci-pfs-2002-11-15-WINDOW.xsd 
             http://www.xbrl.org/taxonomy/int/fr/ias/pfs/2002-11-15/Novartis-2002-11-15 Novartis-2002-11-15.xsd 
   '>
  ...
</group>

此外,上下文当时有不同的元素名称 (numericContext),持续时间的定义也不同:

 <numericContext id='Group2001ForPeriod' precision='18' cwa='true'>
     <entity>
        <identifier scheme='http://www.novartis.com/group'>Novartis Group</identifier>
     <segment>

     </segment>
     </entity>
     <period>
        <duration>P1Y</duration>
        <endDate>2001-12-31</endDate>
     </period>
     <unit>
        <measure>iso4217:CHF</measure>
     </unit>
     <scenario><novartis:scenarioType>actual</novartis:scenarioType></scenario>
  </numericContext>

在最终推荐中,这些元素被称为context

我建议尝试阅读一些提交给 EDGAR 系统的真实文件,因为这些文件是一致的。例如最新的年报可以在here.