xQuery 返回除一个之外的所有值
这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="library.xsd">
<items>
<book asin="0201100886"
created="128135928"
lastLookupTime="128135928">
<uuid>BA57A934-6CDC-11D9-830B-000393D3DE16</uuid>
<title>Compilers</title>
<authors>
<author>Alfred V. Aho</author>
<author>Ravi Sethi</author>
<author>Jeffrey D. Ullman</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>1986-01-01</published>
<price>102.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0122513363" created="128135600" lastLookupTime="128136224">
<uuid>F7468E09-6CDB-11D9-830B-000393D3DE16</uuid>
<title>Database Driven Web Sites</title>
<authors>
<author>Jesse Feiler</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>1998-04-15</published>
<edition>Paperback</edition>
<price>50.95</price>
<purchaseDate>2005-01-22</purchaseDate>
<currentValue>35.00</currentValue>
<netRating>1.5</netRating>
<genres>
<genre>Computer Bks - Internet</genre>
<genre>Computer Books: Web Programming</genre>
<genre>Computer Networks</genre>
<genre>Computers</genre>
<genre>Database Management - General</genre>
<genre>Database management</genre>
<genre>Design</genre>
<genre>Distributed Databases</genre>
<genre>Information Technology</genre>
<genre>Internet - Web Site Design</genre>
<genre>Networking - General</genre>
<genre>Web sites</genre>
<genre>Computers / Computer Science</genre>
</genres>
<upc>608628133638</upc>
</book>
<book asin="0201441241"
created="128136896"
lastLookupTime="128136896">
<uuid>FBC45DF4-6CDE-11D9-830B-000393D3DE16</uuid>
<title>Introduction to Automata Theory, Languages, and Computation (2nd Edition)</title>
<authors>
<author>John E. Hopcroft</author>
<author>Rajeev Motwani</author>
<author>Jeffrey D. Ullman</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2000-11-14</published>
<price>108.20</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0471250600"
created="128136896"
lastLookupTime="128136896">
<uuid>FBC7CA56-6CDE-11D9-830B-000393D3DE16</uuid>
<title>Operating System Concepts</title>
<authors>
<author>Abraham Silberschatz</author>
<author>Greg Gagne</author>
<author>Peter Baer Galvin</author>
</authors>
<publisher>Wiley</publisher>
<published>2002-03-08</published>
<price>107.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0321193628"
created="128136896"
lastLookupTime="128136896">
<uuid>FBCB3DCF-6CDE-11D9-830B-000393D3DE16</uuid>
<title>Concepts of Programming Languages, Sixth Edition</title>
<authors>
<author>Robert W. Sebesta</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2003-07-24</published>
<price>112.40</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0138613370" created="128136944" lastLookupTime="128136944">
<uuid>19E5E602-6CDF-11D9-830B-000393D3DE16</uuid>
<title>First Course in Database Systems, A</title>
<authors>
<author>Jeffrey D. Ullman</author>
<author>Jennifer Widom</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>1997-04-02</published>
<edition>Hardcover</edition>
<price>67.00</price>
<purchaseDate>2005-01-22</purchaseDate>
<netRating>3.2</netRating>
<genres>
<genre>Computer Books: Database</genre>
<genre>Computers</genre>
<genre>Database Engineering</genre>
<genre>Database Management - General</genre>
<genre>Database management</genre>
</genres>
<recommendations>
<book asin="0130402648"
created="128136952"
lastLookupTime="128136952">
<uuid>1C60074A-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Database System Implementation</title>
<authors>
<author>Hector Garcia-Molina</author>
<author>Jeffrey D. Ullman</author>
<author>Jennifer D. Widom</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>1999-06-11</published>
<price>89.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130319953"
created="128136952"
lastLookupTime="128136952">
<uuid>1C635DB0-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Database Systems: The Complete Book</title>
<authors>
<author>Hector Garcia-Molina</author>
<author>Jeffrey D. Ullman</author>
<author>Jennifer D. Widom</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>2001-10-02</published>
<price>98.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0201976994"
created="128136952"
lastLookupTime="128136952">
<uuid>1C66B7B4-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Computer Networking: A Top-Down Approach Featuring the Internet</title>
<authors>
<author>James F. Kurose</author>
<author>Keith W. Ross</author>
<author>James Kurose</author>
<author>Keith Ross</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2002-07-17</published>
<price>100.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131433512"
created="128136952"
lastLookupTime="128136952">
<uuid>1C6AC88C-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Computer Networks and Internets, Fourth Edition</title>
<authors>
<author>Douglas E Comer</author>
<author>Ralph E. Droms</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>2003-07-28</published>
<price>100.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0262062178"
created="128136952"
lastLookupTime="128136952">
<uuid>1C6E712C-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Essentials of Programming Languages - 2nd Edition</title>
<authors>
<author>Daniel P. Friedman</author>
<author>Mitchell Wand</author>
<author>Christopher T. Haynes</author>
</authors>
<publisher>The MIT Press</publisher>
<published>2001-01-29</published>
<price>62.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0471250600"
created="128136952"
lastLookupTime="128136952">
<uuid>1C71B23E-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Operating System Concepts</title>
<authors>
<author>Abraham Silberschatz</author>
<author>Greg Gagne</author>
<author>Peter Baer Galvin</author>
</authors>
<publisher>Wiley</publisher>
<published>2002-03-08</published>
<price>107.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0137903952"
created="128136952"
lastLookupTime="128136952">
<uuid>1C764AD4-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Artificial Intelligence: A Modern Approach (2nd Edition)</title>
<authors>
<author>Stuart J. Russell</author>
<author>Peter Norvig</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>2002-12-20</published>
<price>93.33</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="155860832X"
created="128136952"
lastLookupTime="128136952">
<uuid>1C898640-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Computer Networks: A Systems Approach, 3rd Edition</title>
<authors>
<author>Larry L. Peterson</author>
<author>Bruce S. Davie</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>2003-05-22</published>
<price>89.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130669474"
created="128136952"
lastLookupTime="128136952">
<uuid>1C8DD37A-6CDF-11D9-830B-000393D3DE16</uuid>
<title>SQL Fundamentals (2nd Edition)</title>
<authors>
<author>John J. Patrick</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2002-05-07</published>
<price>54.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0321122267"
created="128136952"
lastLookupTime="128136952">
<uuid>1C91D772-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Fundamentals of Database Systems, Fourth Edition</title>
<authors>
<author>Ramez Elmasri</author>
<author>Shamkant B. Navathe</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2003-07-23</published>
<price>104.20</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
</recommendations>
</book>
<book asin="1558604820" created="128136024" lastLookupTime="128136024">
<uuid>F3C7B24F-6CDC-11D9-830B-000393D3DE16</uuid>
<title>A Complete Guide to DB2 Universal Database</title>
<authors>
<author>D. D. Chamberlin</author>
<author>Don Chamberlin</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>1998-08-15</published>
<edition>Paperback</edition>
<price>62.95</price>
<purchaseDate>2005-01-22</purchaseDate>
<netRating>4.4</netRating>
<genres>
<genre>Computer Bks - Data Base Management</genre>
<genre>Computer Books: Database</genre>
<genre>Computers</genre>
<genre>Database Management - General</genre>
<genre>General</genre>
<genre>IBM Database 2</genre>
<genre>Information Storage & Retrieval</genre>
<genre>Relational Databases</genre>
<genre>Computers / Information Storage & Retrieval</genre>
</genres>
<recommendations>
<book asin="0072133449"
created="128136024"
lastLookupTime="128136024">
<uuid>F6B35F21-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2: The Complete Reference (Complete Reference Series)</title>
<authors>
<author>Roman B. Melnyk</author>
<author>Paul C. Zikopoulos</author>
</authors>
<publisher>McGraw-Hill Companies</publisher>
<published>2001-10-01</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130661112"
created="128136024"
lastLookupTime="128136024">
<uuid>F6B97E54-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 UDB v8 Handbook for Windows and UNIX/Linux</title>
<authors>
<author>Philip K. Gunning</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-08-06</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131007726"
created="128136024"
lastLookupTime="128136024">
<uuid>F6BCBB88-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 SQL Procedural Language for Linux, Unix and Windows</title>
<authors>
<author>Paul Yip</author>
<author>Drew Bradstock</author>
<author>Hana Curtis</author>
<author>Michael Gao</author>
<author>Zamil Janmohamed</author>
<author>Clara Liu</author>
<author>Fraser McArthur</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2002-12-24</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131424653"
created="128136024"
lastLookupTime="128136024">
<uuid>F6C0A296-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 UDB V8.1 Certification Exam 700 Study Guide</title>
<authors>
<author>Roger E. Sanders</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-09-17</published>
<price>49.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0764508415"
created="128136024"
lastLookupTime="128136024">
<uuid>F6C4058C-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 Fundamentals Certification for Dummies</title>
<authors>
<author>Paul C. Zikopoulos</author>
<author>Jennifer Gibbs</author>
<author>Roman B. Melnyk</author>
</authors>
<publisher>For Dummies</publisher>
<published>2001-08-01</published>
<price>34.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130463612"
created="128136024"
lastLookupTime="128136024">
<uuid>F6D9A3D8-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 Universal Database V8 for Linux, UNIX, and Windows Database Administration Certification Guide (5th Edition)</title>
<authors>
<author>George Baklarz</author>
<author>Bill Wong</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-02-10</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130463884"
created="128136024"
lastLookupTime="128136024">
<uuid>F6DDBAB9-6CDC-11D9-830B-000393D3DE16</uuid>
<title>Advanced DBA Certification Guide and Reference for DB2 UDB v8 for Linux, Unix and Windows</title>
<authors>
<author>Dwaine R. Snow</author>
<author>Thomas Xuan Phan</author>
<author>Dwaine Snow</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-07-07</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="155860443X"
created="128136024"
lastLookupTime="128136024">
<uuid>F6E1063D-6CDC-11D9-830B-000393D3DE16</uuid>
<title>Advanced Database Systems (The Morgan Kaufmann Series in Data Management Systems)</title>
<authors>
<author>Carlo Zaniolo</author>
<author>Stefano Ceri</author>
<author>Christos Faloutsos</author>
<author>Richard T. Snodgrass</author>
<author>V. S. Subrahmanian</author>
<author>Roberto Zicari</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>1997-05-01</published>
<price>88.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131840487"
created="128136024"
lastLookupTime="128136024">
<uuid>F6E441CE-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 UDB V8.1 Certification Exams 701 and 706 Study Guide</title>
<authors>
<author>Roger E. Sanders</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-12-12</published>
<price>49.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0132037955"
created="128136024"
lastLookupTime="128136024">
<uuid>F6E77C2C-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 High Performance Design and Tuning</title>
<authors>
<author>Richard Yevich</author>
<author>Susan Lawson</author>
<author>Richard A. Yevich</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2000-08-24</published>
<price>54.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
</recommendations>
</book>
</items>
<borrowers>
<borrower id="1">
<name> John Doe </name>
<phone> 555-1212 </phone>
<borrowed>
<book asin="0138613370"/>
<book asin="0122513363"/>
</borrowed>
</borrower>
<borrower id="2">
<name> Mary Jane </name>
<phone> 555-1213 </phone>
<borrowed>
<book asin="0201100886"/>
<book asin="0122513363"/>
</borrowed>
</borrower>
<borrower id="3">
<name> Bill Jones </name>
<phone> 555-1312 </phone>
<borrowed />
</borrower>
<borrower id="4">
<name> Anne Marie</name>
<phone> 555-1314</phone>
<borrowed>
<book asin="0138613370"/>
<book asin="0201100886"/>
<book asin="0122513363"/>
<book asin="1558604820"/>
</borrowed>
</borrower>
这是我的 XQuery:
xquery version "1.0";
for $library in doc("library.xml")/library
for $book in $library/items/book
let $borrowed := $library/borrowers/borrower/borrowed/book
where not($borrowed[@asin = $book/@asin])
and ($book/authors/author = "Jeffrey D. Ullman")
return
if($book/authors/author != "Jeffrey D. Ullman")
then <librarytitle>{$book/authors/author}</librarytitle>
else <librarytitle/>
我需要返回 Jeff D Ullman 是合著者的所有作者,但在列表中我无法返回他的名字。所以我把他写的所有书都拿出来打印出来。如果他的名字在那里,请不要打印出来。我的 if then else 语句不起作用。有什么想法吗????
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="library.xsd">
<items>
<book asin="0201100886"
created="128135928"
lastLookupTime="128135928">
<uuid>BA57A934-6CDC-11D9-830B-000393D3DE16</uuid>
<title>Compilers</title>
<authors>
<author>Alfred V. Aho</author>
<author>Ravi Sethi</author>
<author>Jeffrey D. Ullman</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>1986-01-01</published>
<price>102.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0122513363" created="128135600" lastLookupTime="128136224">
<uuid>F7468E09-6CDB-11D9-830B-000393D3DE16</uuid>
<title>Database Driven Web Sites</title>
<authors>
<author>Jesse Feiler</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>1998-04-15</published>
<edition>Paperback</edition>
<price>50.95</price>
<purchaseDate>2005-01-22</purchaseDate>
<currentValue>35.00</currentValue>
<netRating>1.5</netRating>
<genres>
<genre>Computer Bks - Internet</genre>
<genre>Computer Books: Web Programming</genre>
<genre>Computer Networks</genre>
<genre>Computers</genre>
<genre>Database Management - General</genre>
<genre>Database management</genre>
<genre>Design</genre>
<genre>Distributed Databases</genre>
<genre>Information Technology</genre>
<genre>Internet - Web Site Design</genre>
<genre>Networking - General</genre>
<genre>Web sites</genre>
<genre>Computers / Computer Science</genre>
</genres>
<upc>608628133638</upc>
</book>
<book asin="0201441241"
created="128136896"
lastLookupTime="128136896">
<uuid>FBC45DF4-6CDE-11D9-830B-000393D3DE16</uuid>
<title>Introduction to Automata Theory, Languages, and Computation (2nd Edition)</title>
<authors>
<author>John E. Hopcroft</author>
<author>Rajeev Motwani</author>
<author>Jeffrey D. Ullman</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2000-11-14</published>
<price>108.20</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0471250600"
created="128136896"
lastLookupTime="128136896">
<uuid>FBC7CA56-6CDE-11D9-830B-000393D3DE16</uuid>
<title>Operating System Concepts</title>
<authors>
<author>Abraham Silberschatz</author>
<author>Greg Gagne</author>
<author>Peter Baer Galvin</author>
</authors>
<publisher>Wiley</publisher>
<published>2002-03-08</published>
<price>107.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0321193628"
created="128136896"
lastLookupTime="128136896">
<uuid>FBCB3DCF-6CDE-11D9-830B-000393D3DE16</uuid>
<title>Concepts of Programming Languages, Sixth Edition</title>
<authors>
<author>Robert W. Sebesta</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2003-07-24</published>
<price>112.40</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0138613370" created="128136944" lastLookupTime="128136944">
<uuid>19E5E602-6CDF-11D9-830B-000393D3DE16</uuid>
<title>First Course in Database Systems, A</title>
<authors>
<author>Jeffrey D. Ullman</author>
<author>Jennifer Widom</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>1997-04-02</published>
<edition>Hardcover</edition>
<price>67.00</price>
<purchaseDate>2005-01-22</purchaseDate>
<netRating>3.2</netRating>
<genres>
<genre>Computer Books: Database</genre>
<genre>Computers</genre>
<genre>Database Engineering</genre>
<genre>Database Management - General</genre>
<genre>Database management</genre>
</genres>
<recommendations>
<book asin="0130402648"
created="128136952"
lastLookupTime="128136952">
<uuid>1C60074A-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Database System Implementation</title>
<authors>
<author>Hector Garcia-Molina</author>
<author>Jeffrey D. Ullman</author>
<author>Jennifer D. Widom</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>1999-06-11</published>
<price>89.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130319953"
created="128136952"
lastLookupTime="128136952">
<uuid>1C635DB0-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Database Systems: The Complete Book</title>
<authors>
<author>Hector Garcia-Molina</author>
<author>Jeffrey D. Ullman</author>
<author>Jennifer D. Widom</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>2001-10-02</published>
<price>98.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0201976994"
created="128136952"
lastLookupTime="128136952">
<uuid>1C66B7B4-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Computer Networking: A Top-Down Approach Featuring the Internet</title>
<authors>
<author>James F. Kurose</author>
<author>Keith W. Ross</author>
<author>James Kurose</author>
<author>Keith Ross</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2002-07-17</published>
<price>100.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131433512"
created="128136952"
lastLookupTime="128136952">
<uuid>1C6AC88C-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Computer Networks and Internets, Fourth Edition</title>
<authors>
<author>Douglas E Comer</author>
<author>Ralph E. Droms</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>2003-07-28</published>
<price>100.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0262062178"
created="128136952"
lastLookupTime="128136952">
<uuid>1C6E712C-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Essentials of Programming Languages - 2nd Edition</title>
<authors>
<author>Daniel P. Friedman</author>
<author>Mitchell Wand</author>
<author>Christopher T. Haynes</author>
</authors>
<publisher>The MIT Press</publisher>
<published>2001-01-29</published>
<price>62.00</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0471250600"
created="128136952"
lastLookupTime="128136952">
<uuid>1C71B23E-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Operating System Concepts</title>
<authors>
<author>Abraham Silberschatz</author>
<author>Greg Gagne</author>
<author>Peter Baer Galvin</author>
</authors>
<publisher>Wiley</publisher>
<published>2002-03-08</published>
<price>107.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0137903952"
created="128136952"
lastLookupTime="128136952">
<uuid>1C764AD4-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Artificial Intelligence: A Modern Approach (2nd Edition)</title>
<authors>
<author>Stuart J. Russell</author>
<author>Peter Norvig</author>
</authors>
<publisher>Prentice Hall</publisher>
<published>2002-12-20</published>
<price>93.33</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="155860832X"
created="128136952"
lastLookupTime="128136952">
<uuid>1C898640-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Computer Networks: A Systems Approach, 3rd Edition</title>
<authors>
<author>Larry L. Peterson</author>
<author>Bruce S. Davie</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>2003-05-22</published>
<price>89.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130669474"
created="128136952"
lastLookupTime="128136952">
<uuid>1C8DD37A-6CDF-11D9-830B-000393D3DE16</uuid>
<title>SQL Fundamentals (2nd Edition)</title>
<authors>
<author>John J. Patrick</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2002-05-07</published>
<price>54.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0321122267"
created="128136952"
lastLookupTime="128136952">
<uuid>1C91D772-6CDF-11D9-830B-000393D3DE16</uuid>
<title>Fundamentals of Database Systems, Fourth Edition</title>
<authors>
<author>Ramez Elmasri</author>
<author>Shamkant B. Navathe</author>
</authors>
<publisher>Addison Wesley</publisher>
<published>2003-07-23</published>
<price>104.20</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
</recommendations>
</book>
<book asin="1558604820" created="128136024" lastLookupTime="128136024">
<uuid>F3C7B24F-6CDC-11D9-830B-000393D3DE16</uuid>
<title>A Complete Guide to DB2 Universal Database</title>
<authors>
<author>D. D. Chamberlin</author>
<author>Don Chamberlin</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>1998-08-15</published>
<edition>Paperback</edition>
<price>62.95</price>
<purchaseDate>2005-01-22</purchaseDate>
<netRating>4.4</netRating>
<genres>
<genre>Computer Bks - Data Base Management</genre>
<genre>Computer Books: Database</genre>
<genre>Computers</genre>
<genre>Database Management - General</genre>
<genre>General</genre>
<genre>IBM Database 2</genre>
<genre>Information Storage & Retrieval</genre>
<genre>Relational Databases</genre>
<genre>Computers / Information Storage & Retrieval</genre>
</genres>
<recommendations>
<book asin="0072133449"
created="128136024"
lastLookupTime="128136024">
<uuid>F6B35F21-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2: The Complete Reference (Complete Reference Series)</title>
<authors>
<author>Roman B. Melnyk</author>
<author>Paul C. Zikopoulos</author>
</authors>
<publisher>McGraw-Hill Companies</publisher>
<published>2001-10-01</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130661112"
created="128136024"
lastLookupTime="128136024">
<uuid>F6B97E54-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 UDB v8 Handbook for Windows and UNIX/Linux</title>
<authors>
<author>Philip K. Gunning</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-08-06</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131007726"
created="128136024"
lastLookupTime="128136024">
<uuid>F6BCBB88-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 SQL Procedural Language for Linux, Unix and Windows</title>
<authors>
<author>Paul Yip</author>
<author>Drew Bradstock</author>
<author>Hana Curtis</author>
<author>Michael Gao</author>
<author>Zamil Janmohamed</author>
<author>Clara Liu</author>
<author>Fraser McArthur</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2002-12-24</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131424653"
created="128136024"
lastLookupTime="128136024">
<uuid>F6C0A296-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 UDB V8.1 Certification Exam 700 Study Guide</title>
<authors>
<author>Roger E. Sanders</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-09-17</published>
<price>49.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0764508415"
created="128136024"
lastLookupTime="128136024">
<uuid>F6C4058C-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 Fundamentals Certification for Dummies</title>
<authors>
<author>Paul C. Zikopoulos</author>
<author>Jennifer Gibbs</author>
<author>Roman B. Melnyk</author>
</authors>
<publisher>For Dummies</publisher>
<published>2001-08-01</published>
<price>34.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130463612"
created="128136024"
lastLookupTime="128136024">
<uuid>F6D9A3D8-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 Universal Database V8 for Linux, UNIX, and Windows Database Administration Certification Guide (5th Edition)</title>
<authors>
<author>George Baklarz</author>
<author>Bill Wong</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-02-10</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0130463884"
created="128136024"
lastLookupTime="128136024">
<uuid>F6DDBAB9-6CDC-11D9-830B-000393D3DE16</uuid>
<title>Advanced DBA Certification Guide and Reference for DB2 UDB v8 for Linux, Unix and Windows</title>
<authors>
<author>Dwaine R. Snow</author>
<author>Thomas Xuan Phan</author>
<author>Dwaine Snow</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-07-07</published>
<price>59.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="155860443X"
created="128136024"
lastLookupTime="128136024">
<uuid>F6E1063D-6CDC-11D9-830B-000393D3DE16</uuid>
<title>Advanced Database Systems (The Morgan Kaufmann Series in Data Management Systems)</title>
<authors>
<author>Carlo Zaniolo</author>
<author>Stefano Ceri</author>
<author>Christos Faloutsos</author>
<author>Richard T. Snodgrass</author>
<author>V. S. Subrahmanian</author>
<author>Roberto Zicari</author>
</authors>
<publisher>Morgan Kaufmann</publisher>
<published>1997-05-01</published>
<price>88.95</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0131840487"
created="128136024"
lastLookupTime="128136024">
<uuid>F6E441CE-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 UDB V8.1 Certification Exams 701 and 706 Study Guide</title>
<authors>
<author>Roger E. Sanders</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2003-12-12</published>
<price>49.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
<book asin="0132037955"
created="128136024"
lastLookupTime="128136024">
<uuid>F6E77C2C-6CDC-11D9-830B-000393D3DE16</uuid>
<title>DB2 High Performance Design and Tuning</title>
<authors>
<author>Richard Yevich</author>
<author>Susan Lawson</author>
<author>Richard A. Yevich</author>
</authors>
<publisher>Prentice Hall PTR</publisher>
<published>2000-08-24</published>
<price>54.99</price>
<purchaseDate>2005-01-22</purchaseDate>
</book>
</recommendations>
</book>
</items>
<borrowers>
<borrower id="1">
<name> John Doe </name>
<phone> 555-1212 </phone>
<borrowed>
<book asin="0138613370"/>
<book asin="0122513363"/>
</borrowed>
</borrower>
<borrower id="2">
<name> Mary Jane </name>
<phone> 555-1213 </phone>
<borrowed>
<book asin="0201100886"/>
<book asin="0122513363"/>
</borrowed>
</borrower>
<borrower id="3">
<name> Bill Jones </name>
<phone> 555-1312 </phone>
<borrowed />
</borrower>
<borrower id="4">
<name> Anne Marie</name>
<phone> 555-1314</phone>
<borrowed>
<book asin="0138613370"/>
<book asin="0201100886"/>
<book asin="0122513363"/>
<book asin="1558604820"/>
</borrowed>
</borrower>
Here is my XQuery:
xquery version "1.0";
for $library in doc("library.xml")/library
for $book in $library/items/book
let $borrowed := $library/borrowers/borrower/borrowed/book
where not($borrowed[@asin = $book/@asin])
and ($book/authors/author = "Jeffrey D. Ullman")
return
if($book/authors/author != "Jeffrey D. Ullman")
then <librarytitle>{$book/authors/author}</librarytitle>
else <librarytitle/>
I need to return all authors where Jeff D Ullman is a coauthor but in the list I cant return his name. So i get all books he is an author in and print them out. If his name is there dont print it out. My if then else statement is not working. Any ideas????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此 XQuery:
输出:
This XQuery:
Output:
看来你把事情搞得有点复杂了。查看您的 XQuery,您似乎正在尝试列出与 Jeff D. Ullman 合着书籍的所有作者。您似乎还排除了借阅的书籍。
如果您查看 XML,您会发现有 3 本书的作者是 Jeff Ullman。以下是 3 中的
@asin
值:在这 3 本书中,其中 2 本书被借阅:(
注意:这两本书都出现了两次,因为有 2 个不同的借阅者借了这些书。
)只留下书
/library[1]/items[1]/book[3]/@asin - 0201441241
。这本书只有 2 位合著者。下面的 XQuery 返回合著者的正确姓名。
XQuery
结果
It looks like you are over complicating it a little bit. Looking at your XQuery, it appears that you are trying to list all authors that coauthored books with Jeff D. Ullman. It also appears that you are excluding books that are borrowed.
If you look at your XML, you'll see that there are 3 books that have Jeff Ullman as an author. Here are the
@asin
values from the 3:Of these 3 books, 2 of them are borrowed:
(Note: Both books show up twice because there are 2 different borrowers that have borrowed these books.)
This only leaves the book
/library[1]/items[1]/book[3]/@asin - 0201441241
. This book only has 2 coauthors.The XQuery below returns the correct names of the coauthors.
XQuery
Results