1

我正在尝试(但没有成功)对 XBRL 文档中的子项进行计数。我想知道使用了多少按命名空间前缀分组的模式、单元、上下文和事实。

输入:

<?xml version="1.0" encoding="utf-8"?>
<xbrl xml:lang="en" xmlns="http://www.xbrl.org/2003/instance"  
      xmlns:link="http://www.xbrl.org/2003/linkbase" 
      xmlns:find="http://www.eurofiling.info/xbrl/ext/filing-indicators" 
      xmlns:xlink="http://www.w3.org/1999/xlink"  >
  <link:schemaRef xlink:type="simple" xlink:href="http://www.eba.europa.eu/eu/fr/xbrl/crr/fws/corep/its-2013-02/2014-03-31/mod/corep_le_con.xsd" />
  <context id="I-2014-9-E">
    <entity>
      <identifier scheme="http://www.dnb.nl/id">123</identifier>
    </entity>
    <period>
      <instant>2014-09-30</instant>
    </period>
  </context>
  <unit id="u-EUR">
    <measure>iso4217:EUR</measure>
  </unit>
  <unit id="u-pure">
    <measure>pure</measure>
  </unit>
  <find:fIndicators>
    <find:filingIndicator contextRef="I-2014-9-E">C_00.01</find:filingIndicator>
  </find:fIndicators>
  <find:fIndicators>
    <find:filingIndicator contextRef="I-2014-9-E">C_26.00</find:filingIndicator>
  </find:fIndicators>
  <find:fIndicators>
    <find:filingIndicator contextRef="I-2014-9-E">C_27.00</find:filingIndicator>
  </find:fIndicators>
</xbrl>

想要的输出:

<?xml version="1.0" encoding="utf-8"?>
<XBRLfacts xmlns="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase">
  <linkCount>1</linkCount>
  <unitCount>2</unitCount>
  <contextCount></contextCount>
  <factCount>
    <find>3</find>
  </factCount>
</XBRLfacts>

XSLT 试过:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase"  >
  <xsl:output method="xml" encoding="UTF-8" indent="yes" media-type="text/xml" />

  <xsl:template match="/">
    <XBRLfacts >
        <linkCount>
            <xsl:value-of select="//xbrl/link:schemaRef" />
        </linkCount>
        <unitCount>
            <xsl:value-of select="//xbrl/unit" />
        </unitCount>
        <contextCount>
            <xsl:value-of select="//xbrl/context" />
        </contextCount>
        <!-- something for the facts -->
    </XBRLfacts>
  </xsl:template>

</xsl:stylesheet>

得到的输出:

<?xml version="1.0" encoding="utf-8"?>
<XBRLfacts xmlns="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase">
  <linkCount></linkCount>
  <unitCount></unitCount>
  <contextCount></contextCount>
</XBRLfacts>

非常感谢任何告诉我我做错了什么的帮助。

谢谢。

保罗。

4

1 回答 1

1

您的源元素位于命名空间中。您必须为每个命名空间分配一个前缀,并在寻址该命名空间中的元素时使用它。

另一件事是你实际上并没有计算任何东西。

XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.xbrl.org/2003/instance"
xmlns:xbrl="http://www.xbrl.org/2003/instance"
xmlns:link="http://www.xbrl.org/2003/linkbase"
xmlns:find="http://www.eurofiling.info/xbrl/ext/filing-indicators" 
exclude-result-prefixes="xbrl find">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/xbrl:xbrl">
    <XBRLfacts>
        <linkCount>
            <xsl:value-of select="count(link:schemaRef)" />
        </linkCount>
        <unitCount>
            <xsl:value-of select="count(xbrl:unit)" />
        </unitCount>
        <contextCount>
            <xsl:value-of select="count(xbrl:context)" />
        </contextCount>
        <fIndicatorCount>
            <xsl:value-of select="count(find:fIndicators)" />
        </fIndicatorCount>
    </XBRLfacts>
  </xsl:template>

</xsl:stylesheet>

结果

<?xml version="1.0" encoding="UTF-8"?>
<XBRLfacts xmlns="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase">
  <linkCount>1</linkCount>
  <unitCount>2</unitCount>
  <contextCount>1</contextCount>
  <fIndicatorCount>3</fIndicatorCount>
</XBRLfacts>
于 2014-12-25T15:18:31.240 回答