我正在使用xqilla
在XML文件上运行XQuery脚本:
$ 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>
一旦我取消注释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]
有没有办法解决这个问题?