2

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?

Community
  • 1
  • 1
ExoticBirdsMerchant
  • 1,466
  • 8
  • 28
  • 53

3 Answers3

2

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
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Wow i think it works.... strange you put the first command (declare...) in the place where the xml was – ExoticBirdsMerchant Jun 11 '14 at 17:32
  • Thanks. Just a last wrinkle if i may. I was under the impression (as a very new user) that at the editor window we only put the xml to be queried and not commands...doesn't this use of the editor to put commands create ambiguity?(just asking) – ExoticBirdsMerchant Jun 11 '14 at 17:36
  • 1
    No, the editor window is not where you put the XML to be queried in normal/typical workflows. Generally, that content should be stored in the database (as with the "create database" command). – Charles Duffy Jun 11 '14 at 17:37
  • This whole tutoring has been a ton of gold for me thank you! God Bless! – ExoticBirdsMerchant Jun 11 '14 at 17:38
1

I think in order to query using Clark Notation, you need to prefix with Q:

xquery doc("ann-20140201.xml")//Q{http://xbrl.org/2003/instance}xbrl
wst
  • 11,681
  • 1
  • 24
  • 39
1

The processor shouldn't see the XML declaration (<?xml...?>) as a processing instruction.

Make sure you don't have any whitespace, including linebreaks, before the declaration. It needs to be the very first thing in the file.

Daniel Haley
  • 51,389
  • 6
  • 69
  • 95