2

How to run XQuery script on XML files with explicit schema info using xqilla?

I'm using xqilla to run XQuery scripts on XML files:

$ more BookstoreQ.xml
<?xml version="1.0" ?>
<!-- schema info
<!DOCTYPE Bookstore [
   <!ELEMENT Bookstore (Book | Magazine)*>
   <!ELEMENT Book (Title, Authors, Remark?)>
   <!ATTLIST Book ISBN CDATA #REQUIRED
                  Price CDATA #REQUIRED
                  Edition CDATA #IMPLIED>
   <!ELEMENT Magazine (Title)>
   <!ATTLIST Magazine Month CDATA #REQUIRED Year CDATA #REQUIRED> 
   <!ELEMENT Title (#PCDATA)>
   <!ELEMENT Authors (Author+)>
   <!ELEMENT Remark (#PCDATA)>
   <!ELEMENT Author (First_Name, Last_Name)>
   <!ELEMENT First_Name (#PCDATA)>
   <!ELEMENT Last_Name (#PCDATA)>
]>
-->
<Bookstore>
   <Book ISBN="ISBN-0-13-713526-2" Price="85" Edition="3rd">
      <Title>A First Course in Database Systems</Title>
      <Authors>
         <Author>
            <First_Name>Jeffrey</First_Name>
            <Last_Name>Ullman</Last_Name>
         </Author>
         <Author>
            <First_Name>Jennifer</First_Name>
            <Last_Name>Widom</Last_Name>
         </Author>
      </Authors>
   </Book>
   <Book ISBN="ISBN-0-13-815504-6" Price="100">
      <Title>Database Systems: The Complete Book</Title>
      <Authors>
         <Author>
            <First_Name>Hector</First_Name>
            <Last_Name>Garcia-Molina</Last_Name>
         </Author>
         <Author>
            <First_Name>Jeffrey</First_Name>
            <Last_Name>Ullman</Last_Name>
         </Author>
         <Author>
            <First_Name>Jennifer</First_Name>
            <Last_Name>Widom</Last_Name>
         </Author>
      </Authors>
      <Remark>
         Buy this book bundled with "A First Course" - a great deal!
      </Remark>
   </Book>
   <Book ISBN="ISBN-0-11-222222-3" Price="50">
      <Title>Hector and Jeff's Database Hints</Title>
      <Authors>
         <Author>
            <First_Name>Jeffrey</First_Name>
            <Last_Name>Ullman</Last_Name>
         </Author>
         <Author>
            <First_Name>Hector</First_Name>
            <Last_Name>Garcia-Molina</Last_Name>
         </Author>
      </Authors>
      <Remark>An indispensible companion to your textbook</Remark>
   </Book>
   <Book ISBN="ISBN-9-88-777777-6" Price="25">
      <Title>Jennifer's Economical Database Hints</Title>
      <Authors>
         <Author>
            <First_Name>Jennifer</First_Name>
            <Last_Name>Widom</Last_Name>
         </Author>
      </Authors>
   </Book>
   <Magazine Month="January" Year="2009">
       <Title>National Geographic</Title>
   </Magazine>
   <Magazine Month="February" Year="2009">
       <Title>National Geographic</Title>
   </Magazine>
   <Magazine Month="February" Year="2009">
       <Title>Newsweek</Title>
   </Magazine>
   <Magazine Month="March" Year="2009">
       <Title>Hector and Jeff's Database Hints</Title>
   </Magazine>
</Bookstore>

$more query
let $doc := .
for $node in $doc/Bookstore/*
where $node/@Price < 90 and $node/Authors/Author/Last_Name = "Ullman"
return $node/Title

$ xqilla -i ../BookstoreQ.xml query
<Title>A First Course in Database Systems</Title>
<Title>Hector and Jeff's Database Hints</Title>

The above doesn't work as soon as I uncomment the schema block of code in BookstoreQ.xml:

$ xqilla -i BookstoreQ.xml query
:0:0: error: Error parsing resource: file:///Users/user121/BookstoreQ.xml. Error message: internal subset is not allowed when reusing the grammar [err:FODC0002]

Is there a way to fix this?

What are some alternative XQuery tools that have CLI?

  • Bit of a guess: err:FODC0002 represents the 'Error retrieving resource' message. Though your doctype is valid according to the XML spec, xqilla might not handle it correctly, and expect a public and/or system reference (alone or together with the internal subset). Not sure what would be a good workaround for you. Did you try contacting xqilla implementors and/or file a bug on the sf project page? – grtjn Jan 03 '12 at 09:35
  • possible duplicate of [XQuery: Returning more than one element](http://stackoverflow.com/questions/15318036/xquery-returning-more-than-one-element) – Paul Sweatte Jun 24 '14 at 22:34

0 Answers0