Search code examples
xmlxpathxquerybasexxbrl

Problems using BaseX GUI


I am trying to navigate through an instance by using XPath. I am providing below an excerpt of 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>

I am aware that the root element has a namespace inside. I am using BaseX GUI. According to previous help my root element is {http://xbrl.org/2003/instance}xbrl!

However when i am trying it on an XPath expression like this:

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

and i hit Execute Query i am getting:

Error:
Stopped at C:/Users/Μαρίνος/Desktop/ann-20140201.xml, 1/6:
[XPST0003] Processing instruction has illegal name: 'xml'.

What am i doing wrong? Also i have been advised to use:

declare namespace xbrli=http://xbrl.org/2003/instance;

I am inputting this command from the GUI and i input the command here (do i input the declaration command here?):

enter image description here

BUT i am still getting the same error message as seen above. What must i do with the illegal name: xml?

EDIT_1

wst says use Q with Clark Notation:

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

--> If i hit run it executes with no error. However instead of getting the root element in the Result pane on BaseX as i get it with this command:

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

I get nothing; why that? Also how do i declare a namespace?


Solution

  • Enter the following in the editor window and press "run":

    declare namespace xbrli="http://www.xbrl.org/2003/instance";
    
    http:send-request(
      <http:request method='get'/>,
      'http://www.sec.gov/Archives/edgar/data/874214/000087421414000008/ann-20140201.xml'
    )[2]/xbrli:xbrl
    

    The database is able to retrieve the original document over HTTP and query the root element from it without issue.

    More locally, the following works perfectly as well (after importing the document as a database):

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

    I notice that your namespace declaration in the question doesn't have question marks -- those are important.

    I also have no trouble getting a result from a QName-based query:

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