XQL (XML Query Language) - PowerPoint PPT Presentation

About This Presentation
Title:

XQL (XML Query Language)

Description:

XQL (XML Query Language) Jonathan Robie (Software AG) jonathan.robie_at_sagus.com ... Makoto Murata (Fuji Xerox) murata_at_apsdc.ksp.fujixerox.co.jp ... – PowerPoint PPT presentation

Number of Views:323
Avg rating:3.0/5.0
Slides: 12
Provided by: caen2
Category:
Tags: xml | xql | fuji | language | query

less

Transcript and Presenter's Notes

Title: XQL (XML Query Language)


1
XQL (XML Query Language)
  • Jonathan Robie (Software AG) ltjonathan.robie_at_sagus
    .comgt
  • Eduard Derksen (CSCIO) ltenno_at_att.comgt
  • Peter Fankhauser (GMD-IPSI) ltfankhaus_at_darmstadt.gm
    d.degt
  • Ed Howland (DEGA) ltEd_at_dega.comgt
  • Gerald Huck (GMD-IPSI) lthuck_at_darmstadt.gmd.degt
  • Ingo Macherius (GMD-IPSI) ltmacherius_at_darmstadt.gmd
    .degt
  • Makoto Murata (Fuji Xerox) ltmurata_at_apsdc.ksp.fujix
    erox.co.jpgt
  • Michael Resnick (Object Design, Incorporated)
    ltresnick_at_odi.comgt
  • Harald Schöning (Software AG) ltharald.schoening_at_so
    ftwareag.degt

2
XQL vs. SQL
  • What is the database?
  • SQL A set of tables
  • XQL A set of one or more XML documents.
  • What is the query language?
  • SQL A query language that uses the structure of
    tables as a basic model.
  • XQL A query language that uses the structure of
    XML documents as a basic model.
  • What is the input to a query?
  • SQL The FROM clause determines the tables which
    are examined by the query.
  • XQL A query is given a list of input nodes from
    one or more documents.
  • What is the result of a query?
  • SQL The result of a query is a table containing
    a set of rows this table may serve as the basis
    for further queries.
  • XQL The result of a query is a list of XML
    document nodes, which may serve as the basis for
    further queries.

3
XQL Expressions
  • Terms
  • Namespaces and Names
  • Comparisons
  • Hierarchy and Filters
  • Boolean and Set Operators
  • Grouping Operator
  • Sequence

4
XQL Expressions (cond.)
  • Functions
  • Extensible Functions
  • References (not incorporated into XQL)
  • Joins
  • Renaming Operator
  • Precedence of Operators

5
Learn XQL by Examples
  • Terms
  • A simple string is interpreted as an element
    name
  • Query example author.
  • Attribute names begin with "_at_".
  • Query example address/_at_type'email.
  • Hierarchy
  • Child operator /
  • Query example /novel/author
  • Paths are described from the top down and usually
    the right-most element on the path is returned
  • Descendant operator ("//") indicates any number
    of intervening levels
  • Example novel//address
  • Shows addresses anywhere within ltnovelgt.

6
Learn XQL by Examples (cond.)
  • Filters
  • Filter operator (" ") filters the set of nodes
    to its left based on the conditions inside the
    brackets.
  • Example novel/author/address_at_type'email'
  • Returns addresses each address must have an
    attribute called "type" with the value "email.
  • Boolean Operations and Comparisons
  • Boolean operators can be used to combine
    conditions.
  • Example
  • novel/author Tom _at_gender'male' and
    _at_shoesizegt'9EEEE'
  • Set Operations
  • Can be used to combine Terms or other XQL
    expressions.
  • Example q1 union q2 (also can be written as q1
    q2)
  • Example q1 intersect q2

7
Learn XQL by Examples (cond.)
  • Namespaces and Names
  • Names may be associated with namespace prefixes
  • A namespace prefix can be declared using a
    variable.
  • Example
  • b "http//www.TwiceSoldTales.com"
  • //bbook
  • The first line declares "b" to be a variable
    equivalent to the namespace URI
    "http//www.TwiceSoldTales.com
  • The second line searches for all ltbookgt elements
    in this namespace.
  • Grouping Operator
  • Useful to group results.
  • Example //book .//author
  • The element to the left of the is used to
    group the results of the query within the braces.

8
Learn XQL by Examples (cond.)
  • Sequence Operators
  • a before b (returns a list of all "a"s that
    precede a "b)
  • a after b (returns a list of all
    "a"s that occur after a "b)
  • a, b (returns a list containing all "a"s,
    followed by all "b"s)
  • XQL operators generally maintain document order.
  • Useful for specifying order in return lists.
  • Functions
  • XQL provide some functions.
  • Example
  • element(), element(name)
  • returns elements in the context. If a name
    argument is supplied, returns the elements with
    the given name.
  • count()

9
Learn XQL by Examples (cond.)
  • Extensible Functions
  • Allow users to write their own functions
  • Functions are passed the list of nodes in the
    current context. If the function has parameters,
    these are passed as strings.
  • The result of a function call is also a nodelist.
  • Example
  • User can add a function that computes the average
    for a list of values and call it in an XQL query
  • average(property//price)
  • ltxqlnumbergt 12345.6789 lt/xqlnumbergt
  • Renaming Operator
  • Nodes in a list can be renamed using renaming
    operator "-gt".
  • Example //book-gtabook
  • Rename the book into a new namespace a

10
Learn XQL by Examples (cond.)
  • References
  • XSL provides "id()" function, which returns the
    element containing a given id.
  • Example A/id(_at_HREF)
  • Return the node pointed to by an HREF attribute
    in an ltAgt element
  • Actually it is a join. But this syntax less
    complex than join.
  • XQL extends to incorporate any kind of link, not
    just ID/IDREF.
  • Example A/ref(_at_HREF)
  • Function ref() returns the node (nodes) to which
    an XPointer or HTML HREF points
  • Can specify parameters to this function
  • Example A/ref(_at_HREF, "table")
  • Return the referenced node only if it is a
    'table" element otherwise, will return null.

11
Learn XQL by Examples (cond.)
  • Joins
  • Combine information from multiple sources to
    create one unified view.
  • Example
  • /book isbn title author //review
    reviewer comments
  • Only correct when the database consists only of
    this one book and this one review.
  • /bookiisbn isbn title author
    //reviewisbni reviewer comments
  • using correlation variables to restrict the
    reviews to those that have the same ISBN number
    as the book.
Write a Comment
User Comments (0)
About PowerShow.com