10.1 Chapter 10: XML Sections 10.1-10.3.1 Problems 10.1, 10.2, 10.7 Find an example of using XML in a field of interest to you and describe it to the class.

Slides:



Advertisements
Similar presentations
XML Examples. Bank Information Basic structure: A-101 Downtown 500 … Johnson Alma Surrey … A-101 Johnson …
Advertisements

XML: Extensible Markup Language
Chapter 10: XML. ©Silberschatz, Korth and Sudarshan10.2Database System ConceptsIntroduction XML: Extensible Markup Language Defined by the WWW Consortium.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 10: XML.
1 COS 425: Database and Information Management Systems XML and information exchange.
Misc Topics Amol Deshpande CMSC424. Topics Today  Database system architectures  Client-server  Parallel and Distributed Systems  Object Oriented,
Storage of XML Data XML data can be stored in –Non-relational data stores Flat files –Natural for storing XML –But has all problems discussed in Chapter.
©Silberschatz, Korth and Sudarshan8.1Database System Concepts Chapter 8: Object-Oriented Databases Need for Complex Data Types The Object-Oriented Data.
L13-S1 XML 2003 SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State.
Introduction to XML This material is based heavily on the tutorial by the same name at
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.
XMLII XSchema XSchema XQuery XQuery. XML Schema XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports XML.
XML Query Languages Notes Based on Chapter 10 of Database System Concepts.
XML Databases and introducing their languages, XQuery, XSLT, and XPath
Aalborg University – Department of Production XML Extensible Markup Language Kaj A. Jørgensen Aalborg University, Department of Production XML – Extensible.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Chapter 10: XML. ©Silberschatz, Korth and Sudarshan10.2Database System ConceptsIntroduction XML: Extensible Markup Language Defined by the WWW Consortium.
Computing & Information Sciences Kansas State University Monday. 20 Oct 2008CIS 560: Database System Concepts Lecture 21 of 42 Monday, 20 October 2008.
Lecture 7 of Advanced Databases XML Querying & Transformation Instructor: Mr.Ahmed Al Astal.
 Structure of XML Data  XML Document Schema  Querying and Transformation  Application Program Interfaces to XML  Storage of XML Data  XML Applications.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
©Silberschatz, Korth and Sudarshan10.1Database System ConceptsIntroduction XML: Extensible Markup Language Defined by the WWW Consortium (W3C) Originally.
XML By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Chapter 10: XML.
Maziar Sanaii Ashtiani – SCT – EMU, Fall 2011/12.
Lecture 6 of Advanced Databases XML Querying & Transformation Instructor: Mr.Eyad Almassri.
Computing & Information Sciences Kansas State University Friday, 17 Oct 2007CIS 560: Database System Concepts Lecture 21 of 42 Friday, 17 October 2008.
Chapter 10: XML XML Structure of XML Data XML Document Schema Querying and Transformation Application Program Interfaces to XML Storage of XML Data.
XMLI Structure of XML Data Structure of XML Data XML Document Schema XML Document Schema XPATH XPATH.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
XML. 2 XML- Some Links XML Tutorials – Some Links me=htmlhttp://
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Computing & Information Sciences Kansas State University Thursday, 15 Mar 2007CIS 560: Database System Concepts Lecture 24 of 42 Thursday, 15 March 2007.
Temple University – CIS Dept. CIS616– Principles of Data Management V. Megalooikonomou XML ( based on slides by Silberschatz, Korth and Sudarshan at Bell.
XML Name: Niki Sardjono Class: CS 157A Instructor : Prof. S. M. Lee.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Chapter 23 XML. 2 Introduction  XML: eXtensible Markup Language (What is a Markup language?)  Defined by the WWW Consortium (W3C)  Originally intended.
Database System Concepts Bin Mu at Tongji University Chapter 10: XML.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
CIS750 – Seminar in Advanced Topics in Computer Science Advanced topics in databases – Multimedia Databases V. Megalooikonomou XML ( based on slides by.
©Silberschatz, Korth and Sudarshan10.1Database System Concepts XML Query Languages Notes Based on Chapter 10 of Database System Concepts.
1. XML Structure of XML Data XML Document Schema Querying and Transformation Application Program Interfaces to XML Storage of XML Data XML Applications.
ADT 2010 Introduction to XML, XPath (& XQuery) Chapter 10 in Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
Introduction to DTD A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 10: XML.
Martin Kruliš by Martin Kruliš (v1.1)1.
Chapter 10: XML. XML Structure of XML Data XML Document Schema Querying and Transformation Application Program Interfaces to XML Storage of XML Data XML.
Chapter 8: XML. 2 XML Structure of XML Data XML Document Schema Querying and Transformation Application Program Interfaces to XML Storage of XML Data.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 10: XML.
Chapter 10: XML. ©Silberschatz, Korth and Sudarshan10.2Database System ConceptsIntroduction XML: Extensible Markup Language Defined by the WWW Consortium.
Chapter 10: XML. ©Silberschatz, Korth and Sudarshan10.2Database System ConceptsIntroduction XML: Extensible Markup Language Defined by the WWW Consortium.
L14-S1 XML 2003 SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State.
Chapter 10: XML Introduction  XML: Extensible Markup Language  Defined by the WWW Consortium (W3C)  Originally intended as a document.
ADT 2010 Introduction to (XML, XPath &) XQuery Chapter 10 in Silberschatz, Korth, Sudarshan “Database System Concepts” Stefan Manegold
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 10: XML.
Extensible Markup Language (XML) Pat Morin COMP 2405.
CS 480: Database Systems Lecture 26 March 18, 2013.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
XML: Extensible Markup Language
Unit 4 Representing Web Data: XML
Querying and Transforming XML Data
XML By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Chapter 23: XML Database System concepts,6th Ed.
XML in Web Technologies
XML and Databases.
Database Processing with XML
Chapter 7 Representing Web Data: XML
CSE591: Data Mining by H. Liu
Presentation transcript:

10.1 Chapter 10: XML Sections Problems 10.1, 10.2, 10.7 Find an example of using XML in a field of interest to you and describe it to the class. Define your own DTD for a PowerPoint presentation  why would you do this?  has it been done before?

10.2 XML (Extensible Markup Language) Defined by the WWW Consortium (W3C) Derived from SGML (Standard Generalized Markup Language) Goal: replace HTML for publishing documents on the Web Originally intended as a document markup language, not for databases Discovery: XML is great for exchanging data, not just documents Tags make data (relatively) self-documenting. E.g. what's this: A-101 Downtown 500 A-101 Johnson

10.3Motivation Suppose a bank wants to send a transaction to another bank Importance of data interchange in a networked world Each application area has its own standards for representing info. Examples:  banking: funds transfer  order processing (especially inter-company orders)  scientific data  Chemistry: ChemML, …  Genetics: BSML (Bio-Sequence Markup Language), … Earlier formats based on plain text with line headers indicating the meaning of fields  similar in concept to headers  does not support nesting  tied too closely to low level document structure (lines, spaces, etc)

10.4Mechanics Each XML based standard defines valid elements, using XML type specification languages to specify the syntax  DTD (Document Type Descriptors)  XML Schema  plus textual descriptions of the semantics New tags can be defined as required Many tools for parsing, browsing and querying XML documents/data Structure  Tag: label for a section of data  Element: section of data beginning with and ending with matching Elements must be properly nested  proper: … …....  Improper: … …. Every document must have a single top-level element

10.5 Nested Elements Hayes Main Harrison A-102 Perryridge 400 …..

10.6 Motivation for Nesting Nested data is common in modeling relational databases  example: elements representing customer-id, customer name, and address contained within an order element  with multiple orders, customer name and address are stored redundantly Normalization often replaces nested structures, storing customer name and address information separately But nesting is often appropriate when transferring data since the external application may not have direct access to related data Perryridge an account another account another one

10.7 Structure of XML Data Elements can have attributes A-102 Perryridge 400 Distinction between subelement and attribute  Attributes are part of markup, while subelement contents are part of the document contents  Same information can be represented in two ways – …. – A-101 …

10.8Namespaces XML data has to be exchanged between organizations Same tags may have different meanings in different organizations Specifying a unique string as an element name avoids confusion Avoid using long unique names with XML Namespaces … Downtown Brooklyn … (Xmins:FB... means FB is an abbreviation for

10.9 XML Document Schema Database schemas constrain what information can be stored, and the data types of stored values XML schemas are very important for XML data exchange  to allow a site to interpret data received from another site Two mechanisms for specifying XML schema  Document Type Definition (DTD)  what elements can occur  what attributes can/must an element have  what subelements can/must occur inside each element, and how many times  XML Schema  newer, increasing in use

10.10 Element Specification in DTD DTD syntax  DTD does not constrain data types: all values are strings Subelements can be specified as  names of elements, or  #PCDATA (parsed character data), i.e., character strings  EMPTY (no subelements) or ANY (anything can be a subelement) Example

10.11 More on Subelement Specification Subelement specification may use regular expressions  Notation: – “|” - alternatives – “+” - 1 or more occurrences – “*” - 0 or more occurrences rfp.dtdrfp.dtd (request for promotion into a CM* system) <!DOCTYPE rfp [ <!ELEMENT promotion (req_nbr, is_done?, cm_tag+, src+, obsolete*, dev_comment, test_comment)> <!-- A promotion is a set of working files to be checked into RCS files, and a set of CM tags to be given to the checked-in versions. --> * Configuration Management

10.12 Bank DTD <<!DOCTYPE bank [ ]> A-401 Downtown more accounts Mary Erin Newark...more customers...depositors

10.13 Attributes in DTD For each attribute  name  type  CDATA (characters)  ID (a unique identifier)  IDREF (the ID value of an element in the same document)  IDREFS (0 or more IDREFs) Examples  *  <!ATTLIST customer customer-id ID # REQUIRED accounts IDREFS # REQUIRED > *checking is the default

10.14 Bank DTD with ID and IDREF Attribute Types <!DOCTYPE bank-2[ <!ATTLIST account account-number ID # REQUIRED owners IDREFS # REQUIRED> <!ATTLIST customer customer-id ID # REQUIRED accounts IDREFS # REQUIRED> … declarations for branch_name, balance, customer-name, customer-street... ]> Downtown more accounts Mary Erin Newark...more customers

10.15 bank-2 Downtown 500 Joe Monroe Madison Mary Erin Newark

10.16 Limitations of DTDs No typing of text elements and attributes  All values are strings, no integers, reals, etc. Difficult to specify unordered sets of subelements  Order is usually irrelevant in databases (unlike in the document- layout environment from which XML evolved)  (A | B)* allows specification of an unordered set, but  Cannot ensure that each of A and B occurs only once IDs and IDREFs are untyped  The owners attribute of an account may contain a reference to another account, which is meaningless  owners attribute should ideally be constrained to refer to customer elements

10.17 XML Schema (skip) XML schema: a more sophisticated schema language Supports  typing values  e.g. integer, string, etc  constraints on min/max values  user defined types  is itself specified in XML syntax, unlike DTDs  more standard representation, but verbose  many more features  list types, uniqueness and foreign key constraints, inheritance.. But:  significantly more complicated than DTDs  not yet widely used

10.18 XML Schema Version of Bank DTD (skip) ….. definitions of customer and depositor ….

10.19Examples MusicXML: RSS feeds: Meat and Poultry

Querying and Transforming XML Data Tools for  querying XML data  translating information from anXML schema to another XML or other format XPath  a simple query language consisting of path expressions XQuery  an XML query language with a rich erset of features XSLT  a simple language translating from XML to XML and XML to HTML

10.21XPath Used to address (select) parts of documents with path expressions Path expression: a sequence of steps separated by “/”  like file names in a directory hierarchy Result of path expression: set of values that along with their containing elements/attributes match the specified path /bank-2/customer/customer_name evaluated on the bank-2 data in slide 15 returnsbank-2 data Joe Mary /bank-2/customer/customer_name/text( ) returns the same names without the enclosing tags “/” denotes root of the XML document (above the top-level tag) Query and transformations are based on a tree model of XML data

10.22XPath Selection predicates in [ ] /bank-2/account[balance > 400]  returns account elements with a balance value greater than 400 /bank-2/account[balance]  returns account elements containing a balance subelement Attributes are accessed using /bank-2/account[balance >  returns the account numbers of accounts with balance > 400 count() at the end of a path counts the number of elements in the set generated by the path  /bank-2/account[count(./customer) > 2] returns accounts with > 2 customers

10.23 More XPath Features “|” used for union  |  gives customers with either accounts or loans “//” can be used to skip multiple levels of nodes  a short from for specifying “all descendants”  /bank-2//customer_name  finds any customer_name element anywhere under the /bank-2 element, regardless of the element in which it is contained. “..” specifies the parent

10.24XQuery A general purpose query language for XML data Currently being standardized by W3C Uses flowr (for … let … where … order by …result … ) syntax for  SQL from //uses XPath expressions where  SQL where order by  SQL order by return  SQL select let allows temporary variables, and has no equivalent in SQL E.g. to return customers with negative balnaces sorted by name for $c in /bank/customer where $c/balance < 0 order by $c/customer_name return { $c/* }

10.25XQuery Find all accounts with balance > 400, with each result enclosed in an.. tag for $x in /bank-2/account let $acctno := where $x/balance > 400 return { $acctno } Items in the return clause are XML text unless enclosed in {}, in which case they are evaluated Let clause not really needed here: for $x in /bank-2/account[balance>400] return { }

10.26Joins Joins are similar to SQL for $a in /bank/account, $c in /bank/customer, $d in /bank/depositor where $a/account_number = $d/account_number and $c/customer_name = $d/customer_name return { $c $a }... lots more

10.27XSLT A stylesheet specifies document formatting  e.g. an HTML css may specify font colors and sizes for headings,...  stored outside the document  separate content and presentation XSL  XML Stylesheet Language  originally designed for generating HTML from XML XSLT  a general-purpose transformation language  can translate XML to XML, and XML to HTML XSLT transformations are expressed using rules called templates  combine selection using XPath with construction of results  strung together to produce a document

10.28 Creating XML Output E.g. to wrap results in new XML elements. match specifies a pattern in XPath xsl:value-of selects (outputs) specified values thwarts default behavour of outputing all elements that don't match any template. Output: Joe Mary

10.29XSLT Example of templates strung together: Using an xsl:sort directive inside a template causes all elements matching the template to be sorted

Storing XML Data XML data can be stored in  non-relational data stores  flat files –natural for XML –has problems discussed in Chapter 1 (no concurrency, no recovery, …)  XML database –database built specifically for storing XML data –no commercial-grade systems  relational databases  data is translated into relational form  advantage: mature database systems  disadvantages: overhead of translating data and queries

10.31 Storing XML in Relational Databases Alternatives:  String Representation  Tree Representation  Map to relations

10.32 Tree Representation Model XML data as tree, store using relations nodes(id, type, label, value) child (child_id, parent_id) Nodes: each element/attribute is given a unique identifier, type indicates element/attribute, label: the tag name of the element/name of attribute, value: the text value of the element/attribute Child: captures parent-child relationships in the tree, can add an extra attribute to child to record ordering of children Benefit: can store any XML data, even without DTD Drawbacks:  data is broken up into too many pieces, increasing space overheads  queries require a large number of joins, which can be slow bank (id:1) customer (id:2) account (id: 5) customer_name (id: 3) account_number (id: 7)

Web Services Simple Object Access Protocol (SOAP):  an XML-based protocol for applications to exchange information over HTTP  invokes procedures across applications with distinct databases HTTP: the protocol for sending messages over the internet  see example on next slide Web service: a site providing a collection of SOAP procedures  described using the Web Services Description Language (WSDL)  directories of Web services are described using the Universal Description, Discovery, and Integration (UDDI) standard Stephanie's CS 330 Project

10.34 HTTP Messages E.g. a resource request for a web page: GET /hi.htm HTTP/1.1 Host: xx.wells.edu Accept text/plain The response: HTTP/ OK Content-Type: text/plain Content-Length: 42 Hello there (HTTP/ OK is the header attached to a successfully returned page)

10.35PowerPoint? Chapter 10: XML What is XML? XML: Extensible Markup Language...