简体   繁体   English

BaseX XQuery不返回根元素

[英]BaseX XQuery does not return the root element

I am trying to use an XQuery search like this with BaseX : 我正在尝试对BaseX使用像这样的XQuery搜索:

XQUERY doc("ann-20140201.xml")//xbrl

I am submitting a small excerpt from the original instance: 我正在提交原始实例的一小段摘录:

<?xml version="1.0" encoding="US-ASCII"?>
<xbrli:xbrl xmlns:ann="http://www.anninc.com/20140201" xmlns:dei="http://xbrl.sec.gov/dei/2013-01-31" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:us-gaap="http://fasb.org/us-gaap/2013-01-31" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <link:schemaRef xlink:href="ann-20140201.xsd" xlink:type="simple" />
  <xbrli:context id="FD2011Q4YTD">
    <xbrli:entity>
      <xbrli:identifier scheme="http://www.sec.gov/CIK">0000874214</xbrli:identifier>
    </xbrli:entity>
    <xbrli:period>
      <xbrli:startDate>2011-01-30</xbrli:startDate>
      <xbrli:endDate>2012-01-28</xbrli:endDate>
    </xbrli:period>
  </xbrli:context>
  <xbrli:context id="FD2011Q4YTD_ann_EarningsPerShareReconciliationAxis_ann_EarningsPerShareBasic.Member">
    <xbrli:entity>

However even if it is clear that <xbrl> is the root element when i Execute the Query with BaseX it returns nothing! 但是,即使很清楚 <xbrl>是我使用BaseX执行查询时的元素,它也不会返回任何内容!

How is it possible to return nothing when the equivalent command returns the root? 当等效命令返回根时,如何不返回任何内容?

The equivalent command is: 等效命令为:

XQUERY doc("ann-20140201.xml")//*

As the previous answer have already shown, you need to specify the namespace URI. 如上一个答案所示,您需要指定名称空间URI。 This is one more way to do it: 这是另一种实现方法:

doc("ann-20140201.xml")//Q{http://www.xbrl.org/2003/instance}xbrl

If you are a lazy typer, you may as well use a wildcard: 如果您是懒惰的打字员,则最好使用通配符:

doc("ann-20140201.xml")//*:xbrl

Your root element is {http://xbrl.org/2003/instance}xbrl . 您的根元素是{http://xbrl.org/2003/instance}xbrl Your query is looking for xbrl . 您的查询正在寻找xbrl They're not the same thing. 他们不是一回事。

Try: 尝试:

declare namespace xbrli=http://xbrl.org/2003/instance;
doc("ann-20140201.xml")//xbrli:xbrl

This is a namespace issue. 这是一个名称空间问题。 Namespaces are especially important if combining XML from different sources, eg. 如果将不同来源的XML组合在一起,则命名空间尤其重要。 embedding (X)HTML in RSS feeds, where some elements might share the same names but have different meanings. 将(X)HTML嵌入RSS提要中,其中某些元素可能共享相同的名称,但含义不同。

To solve the problem, register and use this namespace: 要解决此问题,请注册并使用以下名称空间:

declare namespace xbrli = "http://www.xbrl.org/2003/instance";
doc("ann-20140201.xml")//xbrli:xbrl

Both lines can be joined to a single line if you want to continue using the command input field. 如果要继续使用命令输入字段,则可以将这两行合并为一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM