0
votes

I am trying to use an XQuery search like this with BaseX:

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!

How is it possible to return nothing when the equivalent command returns the root?

The equivalent command is:

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

3 Answers

6
votes

As the previous answer have already shown, you need to specify the namespace 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
5
votes

Your root element is {http://xbrl.org/2003/instance}xbrl. Your query is looking for xbrl. They're not the same thing.

Try:

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

This is a namespace issue. Namespaces are especially important if combining XML from different sources, eg. embedding (X)HTML in RSS feeds, where some elements might share the same names but have different meanings.

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.