| By Selim Mimaroglu | Article Rating: |
|
| November 30, 2005 07:15 AM EST | Reads: |
37,987 |
XML Schema of Data
This is the XML Schema of our data taken from XBench (see the References section) (TC/SD). It has the structure information. Figure 8 tells us that "dictionary" is the root element. "dictionary" has more than one "e" children. The "hwg" element is the child of "e," and so on.
Querying eXist Using XPath
You can find all of the queries that were used in this article below. The following sections show similar queries taken from XBench. Using and understanding XPath is easier than XQuery, so we'll examine these queries first (see Figure 9).
The right-most icon, which looks like a pair of binoculars, is labeled "Query the database with XPath." This is slightly mislabeled, because we can use the same window for XQuery. In the middle of the "Query Dialog," make sure that you select the context /db/XBench. This is the collection in which we stored our data.
Query1
Return the entry matching the headword "minute." This query can be expressed in XPath as:
Only one item is returned. Note that total time, for query compilation and execution, is 719 msec (milliseconds). This is pretty good!
XPath:
/dictionary/e[hwg/hw="minute"]
Query1 results
<e id="E2">
<hwg>
<hw>minute</hw>
<pr>1/k96SMVL^2</pr>
<pos>n.</pos>
</hwg>
<et>
<cr>E143</cr>
<cr>E180</cr>
<cr>E530</cr>
<cr>E308</cr>
<cr>E215</cr>
<cr>E298</cr>
<cr>E294</cr>
</et>
...
Query2
Find the headword with matching the quotation year "1900." This query can be expressed in XPath as:
XPath:
/dictionary/e[ss/s/qp/q/qd="1900"]/hwg/hw
There are 28 matches for this query. Compilation time is 28 msec, execution time is 890 msec. Total time is less than a second. Compilation time reflects the time spent on reading indexes and applying the appropriate algorithms (more on this topic soon). Execution time is the time needed to access the data (stored in DOM format) and return the parts of it that satisfy the query.
Query2 results
<hw>husbandry</hw>
<hw>supper</hw>
<hw>strand</hw>
<hw>nominated</hw>
<hw>saying</hw>
<hw>coram</hw>
<hw>outwards</hw>
<hw>benches</hw>
<hw>faustuses</hw>
<hw>rhapsody</hw>
<hw>rotten</hw>
<hw>punish</hw>
<hw>favours</hw>
<hw>earth</hw>
<hw>italian</hw>
<hw>waits</hw>
<hw>mention</hw>
<hw>sea</hw>
<hw>compelled</hw>
<hw>rumination</hw>
<hw>outrage</hw>
<hw>liege</hw>
<hw>lifted</hw>
<hw>embrace</hw>
<hw>break</hw>
<hw>profession</hw>
<hw>erecting</hw>
<hw>cinna</hw>
Querying eXist Using XQuery
As I mentioned earlier eXist supports XQuery too. At this section we are going to work on two XQuery examples.
Query3
Return quotation text, separated by one unspecified level, matching headword "opinion." This query can be expressed in XQuery as:
XQuery:
for $ent in /dictionary/e
where $ent/*/hw = "opinion"
return
$ent/ss/s/qp/*/qt
Query3 results
<qt>bravely ruthless courts shall lose daringly since the dino</qt>
<qt>doggedly close dinos about the dinos use always about the foxes.ruthlessly
stealt</qt>
<qt>doggedly brave multipliers can nag quietly on the busy realms?dolphins at
the bravely fluf
<cr>E250</cr>
ironic warhorses besides the enticing,
</qt>
...
Items found numbered 20. Compilation time is 16 msec. Execution time is 2469 msec. Total time spent is less than 2.5 seconds. This is a reasonable time for answering a-not-so-easy query. Notice that this query has two stars (*) in it. Star (*) stands for any element.
Published November 30, 2005 Reads 37,987
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Selim Mimaroglu
Selim Mimaroglu is a PhD candidate in computer science at the University of Massachusetts in Boston. He holds an MS in computer science from that school and has a BS in electrical engineering.
![]() |
XML News Desk 11/29/05 07:22:28 PM EST | |||
eXist - An Introduction To Open Source Native XML Database. In this article I am going to introduce you to the open source, free (GNU LGPL license), native XML database eXist (www.exist-db-org). Data is important, no question about it. Data that can't be queried is not very useful. Users expect to have good query response time. From my personal experience and testing, I am confident in saying that eXist is a fairly good database. It has very good query response time, it is very user friendly, it's easy to set up and operate, and it's written in Java, therefore it is platform independent. |
||||
- 4th International Cloud Computing Conference & Expo Starts Today
- Publishing Synergy: Blog, Twitter and Ulitzer
- Performance Tuning Essentials for Java
- Cloud Expo New York Call for Papers Deadline December 15
- Google Wave
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Can Revitalize Your Career as Software Developer
- SOA World Magazine "Readers' Choice Awards" Voting Is Now Open
- Oracle+MySQL Opponents Take to the Barricades
- Virtualization Expo Call for Papers Deadline December 15
- Oracle Faces Growing Price for MySQL
- SpringSource Moving to Spring 3.0
- 4th International Cloud Computing Conference & Expo Starts Today
- Deputy CIO of the CIA to Keynote 1st Annual GovIT Expo
- Publishing Synergy: Blog, Twitter and Ulitzer
- Performance Tuning Essentials for Java
- Cloud Expo New York Call for Papers Deadline December 15
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Google Wave
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Can Revitalize Your Career as Software Developer
- Oracle-Sun: IBM Reportedly Behind Delay
- Citrix Aims To Cripple VMware’s Cloud Designs
- Oracle Trashes HP Relationship for Sun
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- SCO CEO Posts Open Letter to the Open Source Community
- Simula Labs Launches Hosted Delivery Platform To Enable Enterprise Open Source Adoption
- Where Are RIA Technologies Headed in 2008?
- Source Claims SCO Will Sue Google
- How Open Is "Open"? – Industry Luminaries Join the Debate
- Latest SCO News is Plain Weird
- IBM Tells SCO Court It Can't Find AIX-on-Power Code
- SCO Claims Linux Lifted ELF
- Flashback: Investing in 'Professional Open Source' - Exclusive 2004 Interview with David Skok, Matrix Partners
- HP Starts Pushing Desktop Linux
- Linux Business Week Exclusive: Linux Kernel To Be Re-Written To Counter Microsoft FUD
































