Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to run XQuery script on XML files with explicit schema info using xqilla?
    text
    copied!<h2>How to run XQuery script on XML files with explicit schema info using xqilla?</h2> <p>I'm using <a href="http://xqilla.sourceforge.net/HomePage" rel="nofollow"><code>xqilla</code></a> to run XQuery scripts on XML files:</p> <pre><code>$ more BookstoreQ.xml &lt;?xml version="1.0" ?&gt; &lt;!-- schema info &lt;!DOCTYPE Bookstore [ &lt;!ELEMENT Bookstore (Book | Magazine)*&gt; &lt;!ELEMENT Book (Title, Authors, Remark?)&gt; &lt;!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #REQUIRED Edition CDATA #IMPLIED&gt; &lt;!ELEMENT Magazine (Title)&gt; &lt;!ATTLIST Magazine Month CDATA #REQUIRED Year CDATA #REQUIRED&gt; &lt;!ELEMENT Title (#PCDATA)&gt; &lt;!ELEMENT Authors (Author+)&gt; &lt;!ELEMENT Remark (#PCDATA)&gt; &lt;!ELEMENT Author (First_Name, Last_Name)&gt; &lt;!ELEMENT First_Name (#PCDATA)&gt; &lt;!ELEMENT Last_Name (#PCDATA)&gt; ]&gt; --&gt; &lt;Bookstore&gt; &lt;Book ISBN="ISBN-0-13-713526-2" Price="85" Edition="3rd"&gt; &lt;Title&gt;A First Course in Database Systems&lt;/Title&gt; &lt;Authors&gt; &lt;Author&gt; &lt;First_Name&gt;Jeffrey&lt;/First_Name&gt; &lt;Last_Name&gt;Ullman&lt;/Last_Name&gt; &lt;/Author&gt; &lt;Author&gt; &lt;First_Name&gt;Jennifer&lt;/First_Name&gt; &lt;Last_Name&gt;Widom&lt;/Last_Name&gt; &lt;/Author&gt; &lt;/Authors&gt; &lt;/Book&gt; &lt;Book ISBN="ISBN-0-13-815504-6" Price="100"&gt; &lt;Title&gt;Database Systems: The Complete Book&lt;/Title&gt; &lt;Authors&gt; &lt;Author&gt; &lt;First_Name&gt;Hector&lt;/First_Name&gt; &lt;Last_Name&gt;Garcia-Molina&lt;/Last_Name&gt; &lt;/Author&gt; &lt;Author&gt; &lt;First_Name&gt;Jeffrey&lt;/First_Name&gt; &lt;Last_Name&gt;Ullman&lt;/Last_Name&gt; &lt;/Author&gt; &lt;Author&gt; &lt;First_Name&gt;Jennifer&lt;/First_Name&gt; &lt;Last_Name&gt;Widom&lt;/Last_Name&gt; &lt;/Author&gt; &lt;/Authors&gt; &lt;Remark&gt; Buy this book bundled with "A First Course" - a great deal! &lt;/Remark&gt; &lt;/Book&gt; &lt;Book ISBN="ISBN-0-11-222222-3" Price="50"&gt; &lt;Title&gt;Hector and Jeff's Database Hints&lt;/Title&gt; &lt;Authors&gt; &lt;Author&gt; &lt;First_Name&gt;Jeffrey&lt;/First_Name&gt; &lt;Last_Name&gt;Ullman&lt;/Last_Name&gt; &lt;/Author&gt; &lt;Author&gt; &lt;First_Name&gt;Hector&lt;/First_Name&gt; &lt;Last_Name&gt;Garcia-Molina&lt;/Last_Name&gt; &lt;/Author&gt; &lt;/Authors&gt; &lt;Remark&gt;An indispensible companion to your textbook&lt;/Remark&gt; &lt;/Book&gt; &lt;Book ISBN="ISBN-9-88-777777-6" Price="25"&gt; &lt;Title&gt;Jennifer's Economical Database Hints&lt;/Title&gt; &lt;Authors&gt; &lt;Author&gt; &lt;First_Name&gt;Jennifer&lt;/First_Name&gt; &lt;Last_Name&gt;Widom&lt;/Last_Name&gt; &lt;/Author&gt; &lt;/Authors&gt; &lt;/Book&gt; &lt;Magazine Month="January" Year="2009"&gt; &lt;Title&gt;National Geographic&lt;/Title&gt; &lt;/Magazine&gt; &lt;Magazine Month="February" Year="2009"&gt; &lt;Title&gt;National Geographic&lt;/Title&gt; &lt;/Magazine&gt; &lt;Magazine Month="February" Year="2009"&gt; &lt;Title&gt;Newsweek&lt;/Title&gt; &lt;/Magazine&gt; &lt;Magazine Month="March" Year="2009"&gt; &lt;Title&gt;Hector and Jeff's Database Hints&lt;/Title&gt; &lt;/Magazine&gt; &lt;/Bookstore&gt; $more query let $doc := . for $node in $doc/Bookstore/* where $node/@Price &lt; 90 and $node/Authors/Author/Last_Name = "Ullman" return $node/Title $ xqilla -i ../BookstoreQ.xml query &lt;Title&gt;A First Course in Database Systems&lt;/Title&gt; &lt;Title&gt;Hector and Jeff's Database Hints&lt;/Title&gt; </code></pre> <p>The above doesn't work as soon as I uncomment the schema block of code in BookstoreQ.xml:</p> <pre><code>$ 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] </code></pre> <p><strong>Is there a way to fix this?</strong></p> <h2>What are some alternative XQuery tools that have CLI?</h2>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload