0

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")//*
Codo
  • 271
  • 3
  • 10
  • 24

3 Answers3

6

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
Christian Grün
  • 6,012
  • 18
  • 34
5

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
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Wow~ How can an attribute be the root element? i mean we have the "<" symbol and next to it the element name. Please clue me in a bit. – Codo Jun 09 '14 at 16:12
  • @Codo, the root element starts with ``. The part on the left of the `:` specifies the namespace, and there's an `xmlns:xbrli` giving the URL it points to. – Charles Duffy Jun 09 '14 at 16:13
  • I believe it is this one however `xmlns:xbrli="http://www.xbrl.org/2003/instance"`. Am i correct? – Codo Jun 09 '14 at 16:17
  • Yes, that's the namespace declaration used for any element in its scope with its name starting with `xbrli:`. – Charles Duffy Jun 09 '14 at 16:17
4

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.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96