XML Query Languages: XPath, XQuery, and XSLT, Slides of Database Management Systems (DBMS)

An introduction to xml query languages, focusing on xpath, xquery, and xslt. It covers the data model, document nodes, paths in xml documents, path expressions, evaluating a path expression, attributes in paths, wild-card *, selection conditions, axes, xquery, more about item sequences, use of braces, let clauses, order-by clauses, strict comparisons, comparison of elements, getting data from elements, effective boolean values, document order, set operators, and xslt.

Typology: Slides

2012/2013

Uploaded on 04/26/2013

duurga
duurga 🇮🇳

4.6

(25)

121 documents

1 / 75

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Query Languages for XML
XPath
XQuery
XSLT
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b

Partial preview of the text

Download XML Query Languages: XPath, XQuery, and XSLT and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Query Languages for XML

XPath XQuery XSLT

The XPath/XQuery Data Model

  • Corresponding to the fundamental “relation” of the relational model is: sequence of items.
  • An item is either:
    1. A primitive value, e.g., integer or string.
    2. A node (defined next).

Document Nodes

  • Formed by doc(URL) or document(URL).
  • Example: doc(/usr/class/cs145/bars.xml)
  • All XPath (and XQuery) queries refer to a doc node, either explicitly or implicitly. - Example: key definitions in XML Schema have Xpath expressions that refer to the document described by the schema.

DTD for Running Example

]>

Nodes as Semistructured Data

7

BARS

PRICE PRICE

BAR (^) ”JoesBar”name = BEER

theBeer = ”Miller”

theBeer = ”Bud”

SoldBy = ”…”

name = ”Bud”

2.50 3.

Rose =document Green = element Gold = attribute Purple = primitive value

bars.xml

Paths in XML Documents

  • XPath is a language for describing paths in XML documents.
  • The result of the described path is a sequence of items.

Evaluating a Path Expression

  • Assume the first tag is the root.
    • Processing the doc node by this tag results in a sequence consisting of only the root element.
  • Suppose we have a sequence of items, and the next tag is X. - For each item that is an element node, replace the element by the subelements with tag X.

Example: /BARS

2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> …

11

One item, the BARS element Docsity.com

Example: /BARS/BAR/PRICE

2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> …

13

These PRICE elements followed by the PRICE elements of all the other bars.

Attributes in Paths

  • Instead of going to subelements with a given tag, you can go to an attribute of the elements you already have.
  • An attribute is indicated by putting @ in front of its name.

Remember: Item Sequences

  • Until now, all item sequences have been sequences of elements.
  • When a path expression ends in an attribute, the result is typically a sequence of values of primitive type, such as strings in the previous example.

Paths that Begin Anywhere

  • If the path starts from the document node and begins with // X , then the first step can begin at the root or any subelement of the root, as long as the tag is X.

Wild-Card *

  • A star (*) in place of a tag represents any one tag.
  • Example: ///PRICE represents all price objects at the third level of nesting.

Example: /BARS/*

2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> …

(^20)

This BAR element, all other BAR elements, the BEER element, all other BEER elements