xbrl维度链接库解析

xbrl dimensions linkbase parsing

我正在尝试解析 SEC edgar xml 数据,但对 linkable 的定义感到困惑。以下是他们 10-Q 的 linkbase for apple 的定义摘录。注意:roleURI 列是从定义 linkbase.

中的 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 开始,它表示有一个 from link = us-gaap_StatementLineItems and to = us-gaap_StatementTable。从这一点开始,可以通过 table 跟踪以下 links:

from                                 to 
us-gaap_StatementTable               dei_LegalEntityAxis
dei_LegalEntityAxis                  dei_EntityDomain

从这里开始,它停止了,因为 dei_EntityDomain 没有 link 任何东西。我知道结构应该是这样的:

渲染数据:

模型结构:

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

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

我可以看到这将有效地允许两个级别挂起声明 table 但它显然不是那样工作的。

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

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

有一个 table linkbase,旨在帮助呈现实例文档,但我找不到您正在使用的分类法。

这里的诀窍是不要将定义链接库视为 table。严格来说它是一个 acyclic directed graph, but it may help to think of it as a tree with the XBRL hypercube as the root (referred to in your extract as "us-gaap_StatementTable", and in the taxonomy as {http://fasb.org/us-gaap/2015-01-31}StatementTable)。

树的一个分支指向概念或行项目。另一个分支通向轴;在这种情况下,单个维度 {http://xbrl.sec.gov/dei/2014-01-31}LegalEntityAxis with a single possible domain value of {http://xbrl.sec.gov/dei/2014-01-31}EntityDomain.

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

在实例文档中,您将查找 {http://www.xbrl.org/2003/instance}context element with these values as the dimension attribute and value respectively of a child {http://xbrl.org/2006/xbrldi}explicitMember 节点。与此上下文关联的事实将是您所追求的(它们将具有与 parent 上下文的 id[=34= 相同的 contextRef 属性] 属性)。上下文节点也是您获取经期信息的地方。

在我没有帮助的情况下,您发现这里有一个使用抽象元素(us-gaap_OperatingExpensesAbstract、us-gaap_EarningsPerShareAbstract 和 us-gaap_WeightedAverageNumberOfSharesOutstandingAbstract)作为副标题的约定。由于抽象,它们不会出现在实例文档中。

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

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

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}to' 链接以创建以下 table 结构,使用订单字段创建正确的排序:

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

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