xpath-xquery-xslt

xpath-xquery-xslt - 1 Query Languages for XML XPath XQuery...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Query Languages for XML XPath XQuery XSLT 2 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). 3 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. 4 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. 5 DTD for Running Example <!DOCTYPE BARS [ <!ELEMENT BARS (BAR*, BEER*)> <!ELEMENT BAR (PRICE+)> <!ATTLIST BAR name ID #REQUIRED> <!ELEMENT PRICE (#PCDATA)> <!ATTLIST PRICE theBeer IDREF #REQUIRED> <!ELEMENT BEER EMPTY> <!ATTLIST BEER name ID #REQUIRED> <!ATTLIST BEER soldBy IDREFS #IMPLIED> ]> 6 Example Document <BARS> <BAR name = ”JoesBar”> <PRICE theBeer = ”Bud”>2.50</PRICE> <PRICE theBeer = ”Miller”>3.00</PRICE> </BAR> … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … </BARS> An element node An attribute node Document node is all of this, plus the header ( <? xml version… ). 7 Nodes as Semistructured Data BARS PRICE PRICE BEER BAR name = ”JoesBar” theBeer = ”Miller” theBeer = ”Bud” SoldBy = ”…” name = ”Bud” 3.00 2.50 Rose =document Green = element Gold = attribute Purple = primitive value bars.xml 8 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. 9 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. 10 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 . 11 Example : /BARS <BARS> <BAR name = ”JoesBar”> <PRICE theBeer = ”Bud”>2.50</PRICE> <PRICE theBeer = ”Miller”>3.00</PRICE> </BAR> … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar … ”/> … </BARS> One item, the BARS element 12...
View Full Document

This note was uploaded on 02/21/2011 for the course CS 147 taught by Professor Dr.jeff during the Fall '07 term at SUNY Buffalo.

Page1 / 75

xpath-xquery-xslt - 1 Query Languages for XML XPath XQuery...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online