Title: A Graphical Environment to Query XML Data with XQuery
1A Graphical Environment to Query XML Data with
XQuery
2ltbibgt ltbook year"1994"gt lttitlegt
TCP/IP Illustrated lt/titlegt ltauthorgt
ltlastgt Stevens lt/lastgt
ltfirstgt W. lt/firstgt lt/authorgt
ltpublishergt Addison-Wesley lt/publishergt
ltpricegt 65.95 lt/pricegt lt/bookgt ltbook
year"1992"gt lttitlegt Advanced
Programming in the Unix...lt/titlegt
ltauthorgt ltlastgt Stevens lt/lastgt
ltfirstgt W. lt/firstgt lt/authorgt
ltpublishergt Addison-Wesley lt/publishergt
ltpricegt 78.99 lt/pricegt lt/bookgtlt/bibgt
XML data from the W3C Use Cases
3XQuery
- List books published by Addison-Wesley after
1991, including - their year and title
- ltbibgt
- for b in document("www.bn.com/bib.xml")/bib/boo
k - where b/publisher"Addison-Wesley" and
- b/_at_yeargt1991
- return ltbook year" b/_at_year "gt
- b/title
- lt/bookgt
- lt/bibgt
4XQBE (XQuery By Example)
- XQBE, a visual dialect of XQuery inspired by QBE
paradigm (Zloof 77). - The availability of simpler XQuery dialects
could contribute to its success, especially for
users with a very limited experience of query
languages. - To fit the XML data model, XQBE uses hierarchical
structures to denote the data taken in input and
generated as output. Such structures are
annotated to express selection predicates, while
explicit bindings visualize the input/output
mappings.
5Motivation and design principles
- XQBE was designed with the objectives of being
- intuitive
- easy to map directly to XQuery
- capable of running on top of any existing XQuery
engine - XQBE includes most of the expressive power of
XPath - XQBE allows for arbitrarily deep nesting of
XQuery FLWOR expressions - XQBE supports the construction of new XML
elements and permits to restructure existing
documents
6Visual querying paradigm
- A vertical line divides the source (left) part
from the construct (right) part. - The query has a natural reading order from left
to right.
Result data
Source data
Data Flow
Bindings
- The left part describes the data to be matched to
construct the result, the right one specifies
which parts will be retained in the result,
together with (optional) newly generated items.
7XQBE
8- Element projection and renaming
For each book in the bibliography, list the title
and authors, grouped inside a result element
9Element projection and renaming
For each book list only the title and the
surnames of the authors
10Join between two documents
For each book found at both www.bn.com
and www.amazon.com, list the title of the book
and its price from each source
11Document restructuring
Create a flat list of all the title-author pairs,
with each pair enclosed in a result element
12Filtering nodes in the construct part
Make a list of all the books with their title,
including the editors only if they are affiliated
to CITI
13Sorting
List books published by Addison-Wesley after
1991, including their year and title, sorting the
retrieved books in lexicographic order
14Nesting and negation
List all the books not published by
Addison-Wesley and with an author whose first
name is Jack. Rename each of these books in
ltJack-s-bookgt, and only retain the title and the
full name of the authors whose first name is Jack
15Translation principles
- A query translates to one XQuery FLWR expression
- It can be contained into an arbitrary number of
node constructors - The for clause of the outmost FLWR expression
contains a list of variable bindings, each of
which corresponds to a binding edge - Where clauses have a fixed structure
- existential quantifier (some...satisfies)
16The tool in action
17Future works
- Extend the set of supported core functions and
add the capability of querying the document order - Specialize XQBE with capabilities specific to
some applicative domain - An XQBE for digital libraries
- Produce the XQBE view of a given XQuery statement
18Conclusions
- XQBE is a graphical query language that offers a
visual interface to query XML documents. - We have presented a prototype that implements our
proposed interface and translates graphical
queries into XQuery, so that it can be used in
conjunction with any XQuery engine.