XML: Semistructured Data Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 2, 2003 Some slide content courtesy.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

RDF Tutorial.
Normal Forms, XML, and Schemas Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 13, 2005 Some slide content.
Querying XML Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 6, 2003 Some slide content courtesy of Susan Davidson.
1 Lecture 10 XML Wednesday, October 18, XML Outline XML (4.6, 4.7) –Syntax –Semistructured data –DTDs.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
XML, XPath, and XQuery Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 18, 2005 Some slide content courtesy.
1 COS 425: Database and Information Management Systems XML and information exchange.
1 Administrivia  HW3 deadline extended: Tuesday 10/7  Revised upcoming schedule:  Thurs. 10/2: Querying XML  Tues. 10/7: More on XML; beginning of.
Winter 2002Arthur Keller – CS 18018–1 Schedule Today: Mar. 12 (T) u Semistructured Data, XML, XQuery. u Read Sections Assignment 8 due. Mar. 14.
Semi-structured Data. Facts about the Web Growing fast Popular Semi-structured data –Data is presented for ‘human’-processing –Data is often ‘self-describing’
1 Introduction to XML Yanlei Diao UMass Amherst April 19, 2007 Slides Courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives and Gerome Miklau.
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,
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
XML, Schemas, and XPath Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 14, 2004 Some slide content courtesy.
XML Querying and Views Helena Galhardas DEI IST (slides baseados na disciplina CIS 550 – Database & Information Systems, Univ. Pennsylvania, Zachary Ives)CIS.
Querying XML: XPath, XQuery, and XSLT Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 27, 2005 Some slide content.
Schema Normalization, Concluded Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 11, 2005 Some slide content.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
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.
XML Schemas and Queries Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems August 7, 2015.
4/20/2017.
Aalborg University – Department of Production XML Extensible Markup Language Kaj A. Jørgensen Aalborg University, Department of Production XML – Extensible.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
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.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
XML and XPath. Web Services: XML+XPath2 EXtensible Markup Language (XML) a W3C standard to complement HTML A markup language much like HTML origins: structured.
Semistructured data and XML CS 645 April 5, 2006 Some slide content courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
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.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Winter 2006Keller, Ullman, Cushing18–1 Plan 1.Information integration: important new application that motivates what follows. 2.Semistructured data: a.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Indexing and Data Exchange Formats Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems October 17, 2015.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
An OO schema language for XML SOX W3C Note 30 July 1999.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
Web Servers, Data Transmission and Exchange Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems January 29, 2008.
XML Name: Niki Sardjono Class: CS 157A Instructor : Prof. S. M. Lee.
XML Schemas, XPath, and XQuery Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 19, 2004 Some slide content.
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.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
1 “Universal Data-Speak”: The eXtensible Markup Language Zack Ives CSE 590DB, Winter 2000 University of Washington 3 January 2000.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
Martin Kruliš by Martin Kruliš (v1.1)1.
Lecture 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
© 2016 A. Haeberlen, Z. Ives CIS 455/555: Internet and Web Systems 1 University of Pennsylvania XML (continued) February 10, 2016.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
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 Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
XML: Extensible Markup Language
Querying and Transforming XML Data
XML QUESTIONS AND ANSWERS
XML in Web Technologies
Normal Forms and XML Zachary G. Ives October 10, 2007
More XML XML schema, XPATH, XSLT
Presentation transcript:

XML: Semistructured Data Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 2, 2003 Some slide content courtesy of Susan Davidson & Raghu Ramakrishnan

2 Administrivia  HW3 due Tuesday 10/7  Please return HW2s for grade recording (sorry…)  My office is now 576 GRW (5 th floor of the old CIS bldg., by the old stairwell)  Upcoming schedule:  Tues. 10/7: XQuery & XSLT; intro to views; HW4 out(Read Section 3.6 in book)  Thurs. 10/9: Views + datalog, ctd.; review for midterm  Tues. 10/14: Fall Break  Thurs. 10/16: HW4 due; Midterm

3 Why XML? XML is the confluence of several factors:  The Web needed a more declarative format for data  Documents needed a mechanism for extended tags  Database people needed a more flexible interchange format  “Lingua franca” of data  It’s parsable even if we don’t know what it means! Original expectation:  The whole web would go to XML instead of HTML Today’s reality:  Not so… But XML is used all over “under the covers”

4 Why DB People Like XML  Can get data from all sorts of things  Allows us to touch data we don’t own!  This was actually a huge change in the DB community  Interesting relationships with DB techniques  Useful to do relational-style operations  Leverages ideas from object-oriented, semistructured data  Blends schema and data into one format  Unlike relational model, where we need schema first  … But too little schema can be a drawback, too!

5 XML Anatomy Kurt P. Brown PRPL: A Database Workload Specification Language 1992 Univ. of Wisconsin-Madison Paul R. McJones The 1995 SQL Reunion Digital System Research Center Report SRC db/labs/dec/SRC html Processing Instr. Element Attribute Close-tag Open-tag

6 Well-Formed XML A legal XML document – fully parsable by an XML parser  All open-tags have matching close-tags (unlike so many HTML documents!), or a special: shortcut for empty tags (equivalent to  Attributes (which are unordered, in contrast to elements) only appear once in an element  There’s a single root element  XML is case-sensitive

7 XML as a Data Model XML “information set” includes 7 types of nodes:  Document (root)  Element  Attribute  Processing instruction  Text (content)  Namespace:  Comment XML data model includes this, plus typing info, plus order info and a few other things

8 XML Data Model Visualized (and simplified!) Root ?xml dblp mastersthesis article mdate key authortitleyearschool editortitleyearjournalvolumeee mdate key 2002… ms/Brown92 Kurt P…. PRPL… 1992 Univ…. 2002… tr/dec/… Paul R. The… Digital… SRC… 1997 db/labs/dec attribute root p-i element text

9 What Does XML Do?  Serves as a document format that’s better than HTML  Allows custom tags (e.g., used by MS Word, openoffice)  Supplement it with stylesheets (XSL) to define formatting  Provides an exchange format for data (still need to agree on terminology)  Basis for RDF format for describing libraries and the Semantic Web (more on this later)  Format for marshalling and unmarshalling data in SOAP and Web Services

10 XML as a Super-HTML (MS Word) CIS 550: Database and Information Systems Fall Towne, Tuesday/Thursday 1:30PM – 3:00PM

11 XML Easily Encodes Relations sidsernoexp-grade B A B A Student-course-grade

12 But XML is More Flexible… “Non-First-Normal-Form” (NF 2 ) John Joan Jill Felicity …

13 XML and Code  Web Services (.NET, recent Java web service toolkits) are using XML to pass parameters and make function calls  Why?  Easy to be forwards-compatible  Easy to read over and validate (?)  Generally firewall-compatible  Drawbacks? XML is a verbose and inefficient encoding!  XML is used to represent:  SOAP: the “envelope” that data is marshalled into  XML Schema: gives some typing info about structures being passed  WSDL: the IDL (interface def language)  UDDI: provides an interface for querying about web services

14 Integrating XML: What If We Have Multiple Sources with the Same Tags?  Namespaces allow us to specify a context for different tags  Two parts:  Binding of namespace to URI  Qualified names is in namespace myns is the same is a different tag

15 XML Isn’t Enough on Its Own  It’s too unconstrained for many cases!  How will we know when we’re getting garbage?  How will we query?  How will we understand what we got?  We also need:  Some idea of the structure  Our focus next  Presentation, in some cases – XSL(T)  We’ll talk about this soon  Some way of interpreting the tags…?  We’ll talk about this later in the semester

16 Document Type Definitions (DTDs) The DTD is an EBNF grammar defining XML structure  XML document specifies an associated DTD, plus the root element  DTD specifies children of the root (and so on) DTD defines special significance for attributes:  IDs – special attributes that are analogous to keys for elements  IDREFs – references to IDs  IDREFS – a nasty hack that represents a list of IDREFs

17 An Example DTD Example DTD: <!ATTLIST mastersthesis(mdateCDATA#REQUIRED keyID#REQUIRED advisorCDATA#IMPLIED> … Example use of DTD in XML file: …

18 Representing Graphs in XML John Smith Paper1 Paper2 …

19 Graph Data Model Root !DOCTYPE graph author article name title ref John Smith author1 Paper2 ?xml article id author1 author title Paper1

20 Graph Data Model Root !DOCTYPE graph author article name title ref John Smith Paper2 ?xml article id author1 author title Paper1

21 DTDs Aren’t Enough for Some People DTDs capture grammatical structure, but have some drawbacks:  Not themselves in XML – inconvenient to build tools for them  Don’t capture database datatypes’ domains  IDs aren’t a good implementation of keys  Why not?  No way of defining OO-like inheritance  No way of expressing FDs

22 XML Schema Aims to address the shortcomings of DTDs … But an “everything including the kitchen sink” spec Features:  XML syntax  Better way of defining keys using XPaths  Type subclassing that’s more complex than in a programming language  Programming languages don’t consider order of member variables!  Subclassing “by extension” and “by restriction”  … And, of course, domains and built-in datatypes

23 Simple Schema Example

24 Whither XML Schema?  Adopted by a few tools, but…  The jury is still out on this spec  Considered too big, bulky, inconsistent  Still no way of expressing FDs, and the key mechanism isn’t that elegant  Other people have defined more elegant schema languages, FD languages, and key languages (much of the work was here at Penn)  But it’s also at the core of the data model of the XQuery language and the other W3C specs…

25 Designing an XML Schema/DTD  XML data design is generally not as formalized as relational data design  We can still use ER diagrams to break into entity, relationship sets  ER diagrams have extensions for “aggregation” – treating smaller diagrams as entities – and for composite attributes  Note that often we already have our data in relations and need to design the XML schema to export them!  We generally orient the XML tree around the “central” objects in a particular application  A big decision: element vs. attribute  Element if it has its own properties, or if you *might* have more than one of them  Attribute if it is a single property – or perhaps not!

26 XML as a Data Model XML is a non-first-normal-form representation  Can represent documents, data  Standard data exchange format  Several competing schema formats – esp., DTD and XML Schema – provide typing information Now: the core ideas in querying XML

27 Querying XML How do you query a directed graph? a tree? The standard approach used by many XML, semistructured-data, and object query languages:  Define some sort of a template describing traversals from the root of the directed graph  In XML, the basis of this template is called an XPath

28 XPaths In its simplest form, an XPath is like a path in a file system: /mypath/subpath/*/morepath  The XPath returns a node set representing the XML nodes (and their subtrees) at the end of the path  XPaths can have node tests at the end, returning only particular node types, e.g., text(), processing-instruction(), comment(), element(), attribute()  XPath is fundamentally an ordered language: it can query in order-aware fashion, and it returns nodes in order

29 Sample XML Kurt P. Brown PRPL: A Database Workload Specification Language 1992 Univ. of Wisconsin-Madison Paul R. McJones The 1995 SQL Reunion Digital System Research Center Report SRC db/labs/dec/SRC html

30 XML Data Model Visualized Root ?xml dblp mastersthesis article mdate key authortitleyearschool editortitleyearjournalvolumeee mdate key 2002… ms/Brown92 Kurt P…. PRPL… 1992 Univ…. 2002… tr/dec/… Paul R. The… Digital… SRC… 1997 db/labs/dec attribute root p-i element text

31 Some Example XPath Queries  /dblp/mastersthesis/title  /dblp/*/editor  //title  //title/text()

32 Context Nodes and Relative Paths XPath has a notion of a context node: it’s analogous to a current directory  “.” represents this context node  “..” represents the parent node  We can express relative paths: subpath/sub-subpath/../.. gets us back to the context node  By default, the document root is the context node

33 Predicates – Selection Operations A predicate allows us to filter the node set based on selection-like conditions over sub-XPaths: /dblp/article[title = “Paper1”] which is equivalent to: /dblp/article[./title/text() = “Paper1”]

34 Axes: More Complex Traversals Thus far, we’ve seen XPath expressions that go down the tree (and up one step)  But we might want to go up, left, right, etc.  These are expressed with so-called axes:  self::path-step  child::path-stepparent::path-step  descendant::path-stepancestor::path-step  descendant-or-self::path-stepancestor-or-self::path-step  preceding-sibling::path-stepfollowing-sibling::path-step  preceding::path-stepfollowing::path-step  The previous XPaths we saw were in “abbreviated form”

35 Querying Order  We saw in the previous slide that we could query for preceding or following siblings or nodes  We can also query a node for its position according to some index:  fn::first(), fn::last()return index of 0 th & last element matching the last step:  fn::position()gives the relative count of the current node child::article[fn::position() = fn::last()]

36 Users of XPath  XML Schema uses simple XPaths in defining keys and uniqueness constraints  XQuery  XSLT  XLink and XPointer, hyperlinks for XML  Next time we’ll focus on XQuery, the still-under- development “SQL of XML”…  … And we’ll briefly discuss XSLT, a different attempt to manipulate XML data