xbrl维度链接库解析

时间:2016-03-18 15:07:14

标签: xml-parsing xbrl edgar

我正在尝试解析SEC edgar xml数据,并且因为定义可链接而感到困惑。以下是apple 10-Q定义链接库的摘录。注意:roleURI列已从定义链接库中的roleRef元素添加。

idx order   role    {http://www.w3.org/1999/xlink}arcrole   {http://www.w3.org/1999/xlink}from  roleURI {http://www.w3.org/1999/xlink}to
16  1   http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/dimension-domain    dei_LegalEntityAxis aapl-20151226.xsd#Role_StatementOfIncome    dei_EntityDomain
33  1   http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/hypercube-dimension us-gaap_StatementTable  aapl-20151226.xsd#Role_StatementOfIncome    dei_LegalEntityAxis
17  1.01    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_OperatingExpensesAbstract   aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_ResearchAndDevelopmentExpense
18  1.02    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_OperatingExpensesAbstract   aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_SellingGeneralAndAdministrativeExpense
19  1.03    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_OperatingExpensesAbstract   aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_OperatingExpenses
14  1.04    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_EarningsPerShareAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_EarningsPerShareBasic
15  1.05    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_EarningsPerShareAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_EarningsPerShareDiluted
21  1.06    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_SalesRevenueNet
22  1.07    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_CostOfGoodsAndServicesSold
23  1.08    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_GrossProfit
24  1.09    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_OperatingExpensesAbstract
25  1.1 http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_OperatingIncomeLoss
26  1.11    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_NonoperatingIncomeExpense
27  1.12    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_IncomeLossFromContinuingOperationsBeforeIncomeTaxesExtraordinaryItemsNoncontrollingInterest
28  1.13    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_IncomeTaxExpenseBenefit
29  1.14    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_NetIncomeLoss
30  1.15    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_EarningsPerShareAbstract
31  1.16    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract
32  1.17    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_CommonStockDividendsPerShareDeclared
34  1.19    http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_WeightedAverageNumberOfSharesOutstandingBasic
35  1.2 http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/domain-member   us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_WeightedAverageNumberOfDilutedSharesOutstanding
20  100 http://www.apple.com/taxonomy/role/StatementOfIncome    http://xbrl.org/int/dim/arcrole/all us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_StatementTable

根据这些数据,我希望能够为Condensed Consolidated Statements of Operations重新创建here格式。

我的问题是我不确定如何解析它。我假设一个从arcrole/all开始,哪个州的链接= us-gaap_StatementLineItems到= us-gaap_StatementTable。从这一点开始,可以通过表格跟踪以下链接:

from                                 to 
us-gaap_StatementTable               dei_LegalEntityAxis
dei_LegalEntityAxis                  dei_EntityDomain

从这里开始,它会停止,因为dei_EntityDomain没有链接到任何内容。我知道结构应该是这样的:

渲染数据:

Rendered Data

模型结构:

Model Structure

我希望linkbase的结构看起来像这样:

from                                 to 
us-gaap_StatementTable               dei_LegalEntityAxis
us-gaap_StatementTable               us-gaap_StatementLineItems

我可以看到这样可以有效地从Statement表中挂起两个级别,但显然不能像那样工作。

有人可以告诉我如何使用提供的定义链接库数据来读取它以达到上图所示的预期结构。一旦我理解了定义链接库的工作原理,我就可以提取事实和概念。

2 个答案:

答案 0 :(得分:2)

定义链接库用于指示给定维度上下文中的有效概念,而不是用于呈现。但是我认为你仍然可以用它来实现你的目标。

有一个table linkbase,用于协助渲染实例文档,但我找不到您正在使用的分类法。

这里的诀窍是不要将定义链接库视为一个表。严格来说它是一个acyclic directed graph,但它可能有助于将其视为以XBRL hypercube 为根的树(在您的摘录中称为" us-gaap_StatementTable& #34;,并在分类中作为{http://fasb.org/us-gaap/2015-01-31} StatementTable)。

树的一个分支指向概念或行项目。另一个分支通向轴;在这种情况下,单个维度{http://xbrl.sec.gov/dei/2014-01-31} LegalEntityAxis,其中一个可能的域值为{http://xbrl.sec.gov/dei/2014-01-31} EntityDomain。

超立方体不会出现在实例文档中,但它所链接的维度和域将会出现。

在实例文档中,您将查找{http://www.xbrl.org/2003/instance}上下文元素,并将这些值分别作为子{http://xbrl.org/2006/xbrldi} explicitMember节点的维度属性和值。与此上下文关联的事实将是您之后的事实(它们将具有与父上下文 id 属性相同的 contextRef 属性)。上下文节点也是您从中获取期间信息的地方。

在没有我帮助的情况下,你已经知道这里有一个约定,使用抽象元素(us-gaap_OperatingExpensesAbstract,us-gaap_EarningsPerShareAbstract和us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract)作为副标题。作为抽象,他们不会出现在实例文档中。

请记住,在定义的链接库提取中,您已经包含了" dei_EntityDomain"并没有指向任何;概念指向超立方体,超立方体指向维度,指向域。用于表示维度和域的XML元素在实例文档中显示为xbrli:context元素的子元素。

答案 1 :(得分:1)

我已经从StatementofIncome角色的演示链接库创建了表的模型结构。

order   preferredLabel  role    {http://www.w3.org/1999/xlink}arcrole   {http://www.w3.org/1999/xlink}from  roleURI {http://www.w3.org/1999/xlink}to
1   http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_IncomeStatementAbstract aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_StatementTable
1   http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementTable  aapl-20151226.xsd#Role_StatementOfIncome    dei_LegalEntityAxis
1   http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   dei_LegalEntityAxis aapl-20151226.xsd#Role_StatementOfIncome    dei_EntityDomain
100 http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementTable  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_StatementLineItems
1.06    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_SalesRevenueNet
1.07    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_CostOfGoodsAndServicesSold
1.08    http://www.xbrl.org/2003/role/totalLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_GrossProfit
1.09    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_OperatingExpensesAbstract
1.01    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_OperatingExpensesAbstract   aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_ResearchAndDevelopmentExpense
1.02    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_OperatingExpensesAbstract   aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_SellingGeneralAndAdministrativeExpense
1.03    http://www.xbrl.org/2003/role/totalLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_OperatingExpensesAbstract   aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_OperatingExpenses
1.04    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_EarningsPerShareAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_EarningsPerShareBasic
1.05    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_EarningsPerShareAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_EarningsPerShareDiluted
1.1 http://www.xbrl.org/2003/role/totalLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_OperatingIncomeLoss
1.11    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_NonoperatingIncomeExpense
1.12    http://www.xbrl.org/2003/role/totalLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_IncomeLossFromContinuingOperationsBeforeIncomeTaxesExtraordinaryItemsNoncontrollingInterest
1.13    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_IncomeTaxExpenseBenefit
1.14    http://www.xbrl.org/2003/role/totalLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_NetIncomeLoss
1.15    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_EarningsPerShareAbstract
1.16    http://www.xbrl.org/2003/role/verboseLabel  http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract
1.17    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_StatementLineItems  aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_CommonStockDividendsPerShareDeclared
1.19    http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_WeightedAverageNumberOfSharesOutstandingBasic
1.2 http://www.xbrl.org/2003/role/terseLabel    http://www.apple.com/taxonomy/role/StatementOfIncome    http://www.xbrl.org/2003/arcrole/parent-child   us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract    aapl-20151226.xsd#Role_StatementOfIncome    us-gaap_WeightedAverageNumberOfDilutedSharesOutstanding

首先,我按顺序排序,然后找到第一个'from'行,其中包含“Abstract”一词。从这里我遍历'links}到'链接,使用order字段创建下表结构,以创建正确的排序:

us-gaap_IncomeStatementAbstract

Statement [Table]                                           us-gaap_StatementTable
    Legal Entity [Axis]                                     dei_LegalEntityAxis
        Entity [Domain]                                     dei_EntityDomain
    Statement [Line Items]                                  us-gaap_StatementLineItems
        Net sales                                           us-gaap_SalesRevenueNet
        Cost of sales                                       us-gaap_CostOfGoodsAndServicesSold
        Gross margin                                        us-gaap_GrossProfit
        Operating expenses:                                 us-gaap_OperatingExpensesAbstract
            Research and development                        us-gaap_ResearchAndDevelopmentExpense
            Selling, general and administrative             us-gaap_SellingGeneralAndAdministrativeExpense
            Total operating expenses                        us-gaap_OperatingExpenses
        Operating income                                    us-gaap_OperatingIncomeLoss
        Other income/(expense), net                         us-gaap_NonoperatingIncomeExpense
        Income before provision for income taxes            us-gaap_IncomeLossFromContinuingOperationsBeforeIn...
        Provision for income taxes                          us-gaap_IncomeTaxExpenseBenefit
        Net income                                          us-gaap_NetIncomeLoss
        Earnings per share:                                 us-gaap_EarningsPerShareAbstract
            Basic                                           us-gaap_EarningsPerShareBasic
            Diluted                                         us-gaap_EarningsPerShareDiluted
        Shares used in computing earnings per share:        us-gaap_WeightedAverageNumberOfSharesOutstandingAb...
            Basic                                           us-gaap_WeightedAverageNumberOfSharesOutstandingBa...
            Diluted                                         us-gaap_WeightedAverageNumberOfDilutedSharesOutsta...
        Cash dividends declared per share                   us-gaap_CommonStockDividendsPerShareDeclared

这与从渲染应用程序创建的模型结构非常相似:

enter image description here