XML Document Type Definitions XML Schema. Motivation for Semistructured data Serves as a model suitable for integration of databases Notations such as.

Slides:



Advertisements
Similar presentations
2/10/05Salman Azhar: Database Systems1 XML Query Languages Salman Azhar XPATH XQUERY These slides use some figures, definitions, and explanations from.
Advertisements

XML: Extensible Markup Language
SQL Queries Principal form: SELECT desired attributes FROM tuple variables –– range over relations WHERE condition about tuple variables; Running example.
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
1 XML DTD & XML Schema Monica Farrow G30
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
1 XPath Path Expressions Conditions. 2 Paths in XML Documents uXPath is a language for describing paths in XML documents. uReally think of the semistructured.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 357 Database Systems I Query Languages for XML.
1 COS 425: Database and Information Management Systems XML and information exchange.
Winter 2002Arthur Keller – CS 18018–1 Schedule Today: Mar. 12 (T) u Semistructured Data, XML, XQuery. u Read Sections Assignment 8 due. Mar. 14.
1 XML Document Type Definitions XML Schema. 2 Well-Formed and Valid XML uWell-Formed XML allows you to invent your own tags. uValid XML conforms to a.
Fall 2001Arthur Keller – CS 18017–1 Schedule Nov. 27 (T) Semistructured Data, XML. u Read Sections Assignment 8 due. Nov. 29 (TH) The Real World,
1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
1 XML Query Languages XPATH XQUERY. 2 XPATH and XQUERY uXPATH is a language for describing paths in XML documents. wReally think of the semistructured.
1 XQuery Values FLWR Expressions Other Expressions.
1 Query Languages for XML XPath XQuery XSLT. 2 The XPath/XQuery Data Model uCorresponding to the fundamental “relation” of the relational model is: sequence.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
4/20/2017.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Document Type Definition.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
XML Semi-structured data XML Document Type Definitions (DTD)
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
CSCE 520- Relational Data Model Lecture 2. Relational Data Model The following slides are reused by the permission of the author, J. Ullman, from the.
Document Type Definitions XML Schema
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
Advance Database S Week-7 Dr.Kwanchai Eurviriyanukul
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Lecture 22 XML querying. 2 Example 31.5 – XQuery FLWOR Expressions ‘=’ operator is a general comparison operator. XQuery also defines value comparison.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
Processing of structured documents Spring 2003, Part 7 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
Winter 2006Keller, Ullman, Cushing18–1 Plan 1.Information integration: important new application that motivates what follows. 2.Semistructured data: a.
XSLT part of XSL (Extensible Stylesheet Language) –includes also XPath and XSL Formatting Objects used to transform an XML document into: –another XML.
1 XQuery uXQuery extends XPath to a query language that has power similar to SQL. uUses the same sequence-of-items data model. uXQuery is an expression.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
Database Systems Part VII: XML Querying Software School of Hunan University
Jeff Ullman: Introduction to XML 1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
Semistructured Data Extensible Markup Language Document Type Definitions Zaki Malik November 04, 2008.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
Tutorial 13 Validating Documents with Schemas
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
Exam II Syllabus uStorage & Buffer Management uIndexing: Btrees & Hash uMulti-dimensional Indexing uQuery processing (relational ops) uQuery optimization.
Semistructured-Data Model. Lu Chaojun, SJTU 2 Semistructured Data Structured data has a separate schema to describe its structure. –Advantage: efficient.
CSCE 520- Relational Data Model Lecture 2. Oracle login Login from the linux lab or ssh to one of the linux servers using your cse username and password.
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
XML Query Languages XPATH XQUERY Zaki Malik November 11, 2008.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
XML Schema – XSLT Week 8 Web site:
XQUERY The contents of this slide are obtained from various sources including, Wikipedia, W3School, Stanford website etc. January 2011 Dr.Kwanchai Eurviriyanukul.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Query Languages for XML
XML: Extensible Markup Language
XML Base de Datos April 20, 2018April 20, 2018April 20, 2018.
Slides are reused by the approval of Jeffrey Ullman’s
Querying and Transforming XML Data
Semistructured-Data Model
Introduction to Database Systems, CS420
XML Base de Datos September 4, 2018September 4, 2018September 4, 2018September 4, 2018.
Query Languages for XML
Select-From-Where Statements Multirelation Queries Subqueries
Presentation transcript:

XML Document Type Definitions XML Schema

Motivation for Semistructured data Serves as a model suitable for integration of databases Notations such as XML are being used to share information on the Web

Well-Formed and Valid XML Well-Formed XML allows you to invent your own tags. Valid XML conforms to a certain DTD. – Document Type Definition

Well-Formed XML Start the document with a declaration, surrounded by. Normal declaration is: – “standalone” = “no DTD provided.” Balance of document is a root tag surrounding nested tags.

Tags Tags are normally matched pairs, as …. Unmatched tags also allowed, as Tags may be nested arbitrarily. XML tags are case-sensitive.

Example: Well-Formed XML Joe’s Bar Bud 2.50 Miller 3.00 … A NAME subelement A BEER subelement Root tag Tags surrounding a BEER element

DTD Structure [ ( )>... more elements... ]>

DTD Elements The description of an element consists of its name (tag), and a parenthesized description of any nested tags. – Includes order of subtags and their multiplicity. Leaves (text elements) have #PCDATA (Parsed Character DATA ) in place of nested tags.

Example: DTD <!DOCTYPE BARS [ ]> A BARS object has zero or more BAR’s nested within. A BAR has one NAME and one or more BEER subobjects. A BEER has a NAME and a PRICE. NAME and PRICE are text.

Element Descriptions Subtags must appear in order shown. A tag may be followed by a symbol to indicate its multiplicity. – * = zero or more. – + = one or more. – ? = zero or one. Symbol | can connect alternative sequences of tags.

Example: Element Description A name is an optional title (e.g., “Prof.”), a first name, and a last name, in that order, or it is an IP address: <!ELEMENT NAME ( (TITLE?, FIRST, LAST) | IPADDR )>

Use of DTD’s 1.Set standalone = “no”. 2.Either: a)Include the DTD as a preamble of the XML document, or b)Follow DOCTYPE and the by SYSTEM and a path to the file where the DTD can be found.

Example (a) <!DOCTYPE BARS [ ]> Joe’s Bar Bud 2.50 Miller 3.00 … The DTD The document

14 Example (b) Assume the BARS DTD is in file bar.dtd. Joe’s Bar Bud 2.50 Miller 3.00 … Get the DTD from the file bar.dtd

Attributes Opening tags in XML can have attributes. In a DTD, declares attributes for element E, along with its datatype.

Example of Attributes Bars can have an attribute kind, a character string describing the bar. Character string type; no tags Attribute is optional opposite: #REQUIRED

Example of Attribute Use In a document that allows BAR tags, we might see: Homma’s Sapporo

ID’s and IDREF’s Attributes can be pointers from one object to another. – Compare to HTML’s NAME = ”foo” and HREF = ”#foo”. Allows the structure of an XML document to be a general graph, rather than just a tree.

Creating ID’s Give an element E an attribute A of type ID. When using tag in an XML document, give its attribute A a unique value. Example:

Creating IDREF’s To allow elements of type F to refer to another element with an ID attribute, give F an attribute of type IDREF. Or, let the attribute have type IDREFS, so the F - element can refer to any number of other elements.

Example of ID’s and IDREF’s A new BARS DTD includes both BAR and BEER sub- elements. BARS and BEERS have ID attributes name. BARS have SELLS subelements, consisting of a number (the price of one beer) and an IDREF theBeer leading to that beer. BEERS have attribute soldBy, which is an IDREFS leading to all the bars that sell it.

The DTD <!DOCTYPE BARS [ ]> Beer elements have an ID attribute called name, and a soldBy attribute that is a set of Bar names. SELLS elements have a number (the price) and one reference to a beer. Bar elements have name as an ID attribute and have one or more SELLS subelements. Explained next

Example of a Document … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …” /> …

Empty Elements We can do all the work of an element in its attributes. – Like BEER in previous example. Another example: SELLS elements could have attribute price rather than a value that is a price.

Example of Empty Element In the DTD, declare: For example use: Note exception to “matching tags” rule

XML Schema A more powerful way to describe the structure of XML documents. XML-Schema declarations are themselves XML documents. – They describe “elements” and the things doing the describing are also “elements.”

Structure of an XML-Schema Document <xs:schema xmlns:xs = ” Defines ”xs” to be the namespace described in the URL shown. Any string in place of ”xs” is OK. So uses of ”xs” within the schema element refer to tags from this namespace.

The xs:element Element Has attributes: 1.name = the tag-name of the element being defined. 2.type = the type of the element. Could be an XML-Schema type, e.g., xs:string. Or the name of a type defined in the document itself.

Example of xs:element <xs:element name = ”NAME” type = ”xs:string” /> Describes elements such as Joe’s Bar

Complex Types To describe elements that consist of subelements, we use xs:complexType. – Attribute name gives a name to the type. Typical subelement of a complex type is xs:sequence, which itself has a sequence of xs:element subelements. – Use minOccurs and maxOccurs attributes to control the number of occurrences of an xs:element.

Example creating a Type for Beers <xs:element name = ”NAME” type = ”xs:string” minOccurs = ”1” maxOccurs = ”1” /> <xs:element name = ”PRICE” type = ”xs:float” minOccurs = ”0” maxOccurs = ”1” /> Exactly one occurrence Like ? in a DTD

An Element of Type beerType Bud 2.50 We don’t know the name of the element of this type.

Example of creating a Type for Bars <xs:element name = ”NAME” type = ”xs:string” minOccurs = ”1” maxOccurs = ”1” /> <xs:element name = ”BEER” type = ”beerType” minOccurs = ”0” maxOccurs = ”unbounded” /> Like * in a DTD

xs:attribute xs:attribute elements can be used within a complex type to indicate attributes of elements of that type. attributes of xs:attribute: – name and type as for xs.element. – use = ”required” or ”optional”.

Example of xs:attribute <xs:attribute name = ”name” type = ”xs:string” use = ”required” /> <xs:attribute name = ”price” type = ”xs:float” use = ”optional” />

An Element of This New Type beerType <xxx name = ”Bud” price = ”2.50” /> We still don’t know the element name. The element is empty, since there are no declared subelements.

Restricted Simple Types xs:simpleType can describe enumerations and range- restricted base types. name is an attribute xs:restriction is a subelement.

Restrictions Attribute base gives the simple type to be restricted, e.g., xs:integer. xs:{min, max}{Inclusive, Exclusive} are four attributes that can give a lower or upper bound on a numerical range. xs:enumeration is a subelement with attribute value that allows enumerated types.

Example of license Attribute for Bar

Example of Prices in Range [1,5) <xs:restriction base = ”xs:float” minInclusive = ”1.00” maxExclusive = ”5.00” />

Keys in XML Schema An xs:element can have an xs:key subelement. Meaning: within this element, all subelements reached by a certain selector path will have unique values for a certain combination of fields. Example: within one BAR element, the name attribute of a BEER element is unique.

Key Example XPath is a query language for XML. All we need to know here is that a path is a sequence of tags separated by /. indicates an attribute rather than a tag.

Foreign Keys An xs:keyref subelement within an xs:element says that within this element, certain values (defined by selector and field(s), as for keys) must appear as values of a certain key.

Example of Foreign Key Suppose that we have declared that subelement NAME of BAR is a key for BARS. – The name of the key is barKey. We wish to declare DRINKER elements that have FREQ subelements. An attribute bar of FREQ is a foreign key, referring to the NAME of a BAR.

Example of a Foreign Key in XML Schema <xs:element name = ”DRINKERS”... <xs:keyref name = ”barRef” refers = ”barKey”

Chapter 12, Programming Languages for XML XPath is a simple language for describing sets of similar paths in a graph of unstructured data XQuery is an extension of XP that adopts something of the style of SQL

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).

Principal Kinds of Nodes 1.Document nodes represent entire documents. 2.Elements are pieces of a document consisting of some opening tag, its matching closing tag (if any), and everything in between. 3.Attributes names that are given values inside opening tags.

Document Nodes Formed by doc(URL) or document(URL). Example: doc(/usr/class/csc/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 <!DOCTYPE BARS [ ]>

Example Document … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … An element node An attribute node Document node is all of this, plus the header ( <? xml version… ).

Nodes as Semistructured Data BARS PRICE BEERBAR name = ”JoesBar” theBeer = ”Miller” theBeer = ”Bud” SoldBy = ”…” name = ”Bud” Rose =document Blue = 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.

Path Expressions Simple path expressions are sequences of slashes (/) and tags, starting with /. – Example: /BARS/BAR/PRICE Construct the result by starting with just the doc node and processing each tag from the left.

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 sub-elements with tag X.

/BARS … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … One item, the BARS element

/BARS/BAR … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … This BAR element followed by all the other BAR elements

/BARS/BAR/PRICE … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … These PRICE elements followed by the PRICE elements of all the other bars.

Attributes in Paths Instead of going to sub-elements with a given tag, you can go to an attribute of the elements you already have. An attribute is indicated by in front of its name.

… <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … These attributes contribute ”Bud” ”Miller” to the result, followed by other theBeer values.

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.

//PRICE … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …”/> … These PRICE elements and any other PRICE elements in the entire document

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.

/BARS/* … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … This BAR element, all other BAR elements, the BEER element, all other BEER elements

Selection Conditions A condition inside […] may follow a tag. If so, then only paths that have that tag and also satisfy the condition are included in the result of a path expression.

Example of Selection Condition /BARS/BAR/PRICE[. < 2.75] … The condition that the PRICE be < $2.75 makes this price but not the Miller price part of the result. The current element.

Example of Attribute in Selection = ”Miller”] … Now, this PRICE element is selected, along with any other prices for Miller.

Axes In general, path expressions allow us to start at the root and execute steps to find a sequence of nodes at each step. At each step, we may follow any one of several axes. The default axis is child:: --- go to all the children of the current set of nodes.

Example of Axes /BARS/BEER is really shorthand for is really shorthand for the attribute:: axis. – Thus, = ”Bud” ] is shorthand for /BARS/BEER[attribute::name = ”Bud”]

More Axes Some other useful axes are: 1.parent:: = parent(s) of the current node(s). 2.descendant-or-self:: = the current node(s) and all descendants. Note: // is really shorthand for this axis. 3.ancestor::, ancestor-or-self, etc. 4.self (the dot).

XQuery XQuery extends XPath to a query language that has power similar to SQL. Uses the same sequence-of-items data model. XQuery is an expression language. – Like relational algebra --- any XQuery expression can be an argument of any other XQuery expression.

More About Item Sequences XQuery will sometimes form sequences of sequences. All sequences are flattened. Example: (1 2 () (3 4)) = ( ). Empty sequence

FLWR Expressions 1.One or more for and/or let clauses. 2.Then an optional where clause. 3.A return clause.

Semantics of FLWR Expressions Each for creates a loop. – let produces only a local definition. At each iteration of the nested loops, if any, evaluate the where clause. If the where clause returns TRUE, invoke the return clause, and append its value to the output.

FOR Clauses for in,... Variables begin with $. A for-variable takes on each item in the sequence denoted by the expression, in turn. Whatever follows this for is executed once for each value of the variable.

FOR Example for $beer in return {$beer} $beer ranges over the name attributes of all beers in our example document. Result is a sequence of BEERNAME elements: Bud Miller... “Expand the en- closed string by replacing variables and path exps. by their values.” Our example BARS document

Use of Braces When a variable name like $x, or an expression, could be text, we need to surround it by braces to avoid having it interpreted literally. – For example: $x is an A-element with value ”$x”, just like foo is an A-element with ”foo” as value. But return $x is unambiguous. You cannot return an untagged string without quoting it, as return ”$x”.

LET Clauses let :=,... Value of the variable becomes the sequence of items defined by the expression. Note let does not cause iteration; for does.

Let Example let $d := document(”bars.xml”) let $beers := return {$beers} Returns one element with all the names of the beers, like: Bud Miller …

Order-By Clauses FLWR is really FLWOR: an order-by clause can precede the return. Form: order by – With optional ascending or descending. The expression is evaluated for each assignment to variables. Determines placement in output sequence.

Order-By Example List all prices for Bud, lowest first. let $d := document(”bars.xml”) for $p in order by $p return $p Generates bindings for $p to PRICE elements. Order those bindings by the values inside the elements (auto- matic coersion). Each binding is evaluated for the output. The result is a sequence of PRICE elements.

Aside: SQL ORDER BY SQL works the same way; it’s the result of the FROM and WHERE that get ordered, not the output. Example: Using R(a,b), SELECT b FROM R WHERE b > 10 ORDER BY a; R tuples with b>10 are ordered by their a-values. Then, the b-values are extracted from these tuples and printed in the same order.

Predicates Normally, conditions imply existential quantification. For example: means “all the bars that have a name.” For example: = ”JoesBar”] gives the set of beers that are sold at Joe’s Bar.

Comparisons Example Let us produce the PRICE elements (from all bars) for all the beers that are sold by Joe’s Bar. The output will be BBP elements with the names of the bar and beer as attributes and the price element as a sub-element.

Comparison Strategy 1.Create a triple for-loop, with variables ranging over all BEER elements, all BAR elements, and all PRICE elements within those BAR elements. 2.Check that the beer is sold at Joe’s Bar and that the name of the beer and theBeer in the PRICE element match. 3.Construct the output element.

The Query let $bars = doc(”bars.xml”)/BARS for $beer in $bars/BEER for $bar in $bars/BAR for $price in $bar/PRICE where = ”JoesBar” and = return {$price} True if ”JoesBar” appears anywhere in the sequence

Strict Comparisons To require that the things being compared are sequences of only one element, use the Fortran comparison operators: – eq, ne, lt, le, gt, ge. Example: eq ”JoesBar” is true only if Joe’s is the only bar selling the beer.

Comparison of Elements and Values When an element is compared to a primitive value, the element is treated as its value, if that value is atomic. For example eq ”2.50” is true if Joe charges $2.50 for Bud.

Comparison of Two Elements It is insufficient that two elements look alike. For example eq is false, even if Joe and Sue charge the same for Bud.

Comparison of Elements (2) For elements to be equal, they must be the same, physically, in the implied document. Subtlety: elements are really pointers to sections of particular documents, not the text strings appearing in the section.

Getting Data From Elements Suppose we want to compare the values of elements, rather than their location in documents. To extract just the value (e.g., the price itself) from an element E, use data(E ).

All the Distinct Prices Example return distinct-values( let $bars = doc(”bars.xml”) return $bars/BARS/BAR/PRICE ) Remember: XQuery is an expression language. A query can appear any place a value can.

Effective Boolean Values The effective boolean value (EBV) of an expression is: 1.The actual value if the expression is of type boolean. 2.FALSE if the expression evaluates to 0, ”” [the empty string], or () [the empty sequence]. 3.TRUE otherwise.

EBV Examples has EBV TRUE or FALSE, depending on whether the name attribute is ”JoesBar”. has EBV TRUE if some bar is named the Golden Rail, and FALSE if there is no such bar.

Boolean Operators E 1 and E 2, E 1 or E 2, not(E ), apply to any expressions. Take EBV’s of the expressions first. For example: not(3 eq 5 or 0) has value TRUE. Also: true() and false() are functions that return values TRUE and FALSE.

Branching Expressions if (E 1 ) then E 2 else E 3 is evaluated by: – Compute the EBV of E 1. – If true, the result is E 2 ; else the result is E 3. For example the PRICE sub-elements of $bar, provided that bar is Joe’s. eq ”JoesBar”) then $bar/PRICE else () Empty sequence. Note there is no if-then expression.

Quantifier Expressions some $x in E 1 satisfies E 2 1.Evaluate the sequence E 1. 2.Let $x (any variable) be each item in the sequence, and evaluate E 2. 3.Return TRUE if E 2 has EBV TRUE for at least one $x. Analogously: every $x in E 1 satisfies E 2

Some Example The bars that sell at least one beer for less than $2. for $bar in doc(”bars.xml”)/BARS/BAR where some $p in $bar/PRICE satisfies $p < 2.00 return Notice: where $bar/PRICE < 2.00 would work as well.

Every Example The bars that sell no beer for more than $5. for $bar in doc(”bars.xml”)/BARS/BAR where every $p in $bar/PRICE satisfies $p <= 5.00 return

Document Order Comparison by document order: >. For example: << is true iff the Bud element appears before the Miller element in the document $d.

Set Operators union, intersect, except operate on sequences of nodes. – Meanings analogous to SQL. – Result eliminates duplicates. – Result appears in document order.