XMLSlide 2Why XML is of Interest to UsXML Data Sharing and ExchangeFrom HTML to XMLHTMLSlide 7Web ServicesXML TerminologyMore XML: AttributesMore XML: Oids and ReferencesXML Semantics: a Tree !XML DataRelational Data as XMLXML is Semi-structured DataSlide 16Slide 17Document Type Definitions DTDVery Simple DTDSlide 20DTD: The Content ModelDTD: Regular ExpressionsQuerying XML DataSample Data for QueriesData Model for XPathXPath: Simple ExpressionsXPath: Restricted Kleene ClosureXpath: Text NodesXpath: WildcardXpath: Attribute NodesXpath: PredicatesXpath: More PredicatesSlide 33Xpath: SummaryComments on XPath?XQueryFLWR (“Flower”) ExpressionsSlide 38Slide 39Slide 40XQuery: NestingSlide 42Slide 43Slide 44Slide 45Slide 46FOR v.s. LETSlide 48Collections in XQueryXMLXMLeXtensible Markup LanguageXML 1.0 – a recommendation from W3C, 1998Roots: SGML (a very nasty language).After the roots: a format for sharing dataWhy XML is of Interest to UsXML is just syntax for dataNote: we have no syntax for relational dataBut XML is not relational: semistructuredThis is exciting because:Can translate any data to XMLCan ship XML over the Web (HTTP)Can input XML into any applicationThus: data sharing and exchange on the WebXML Data Sharing and Exchangeapplicationrelational dataTransformIntegrateWarehouseXML Data WEB (HTTP)applicationapplicationlegacy dataobject-relationalSpecific data management tasksFrom HTML to XMLHTML describes the presentationHTML<h1> Bibliography </h1><p> <i> Foundations of Databases </i> Abiteboul, Hull, Vianu <br> Addison Wesley, 1995<p> <i> Data on the Web </i> Abiteoul, Buneman, Suciu <br> Morgan Kaufmann, 1999<h1> Bibliography </h1><p> <i> Foundations of Databases </i> Abiteboul, Hull, Vianu <br> Addison Wesley, 1995<p> <i> Data on the Web </i> Abiteoul, Buneman, Suciu <br> Morgan Kaufmann, 1999XML<bibliography> <book> <title> Foundations… </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> …</bibliography><bibliography> <book> <title> Foundations… </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> …</bibliography>XML describes the contentWeb ServicesA new paradigm for creating distributed applications?Systems communicate via messages, contracts.Example: order processing system.MS .NET, J2EE – some of the platformsXML – a part of the story; the data format.XML Terminologytags: book, title, author, …start tag: <book>, end tag: </book>elements: <book>…<book>,<author>…</author>elements are nestedempty element: <red></red> abbrv. <red/>an XML document: single root elementwell formed XML document: if it has matching tagsMore XML: Attributes<book price = “55” currency = “USD”> <title> Foundations of Databases </title> <author> Abiteboul </author> … <year> 1995 </year></book><book price = “55” currency = “USD”> <title> Foundations of Databases </title> <author> Abiteboul </author> … <year> 1995 </year></book>attributes are alternative ways to represent dataMore XML: Oids and References<person id=“o555”> <name> Jane </name> </person><person id=“o456”> <name> Mary </name> <children idref=“o123 o555”/></person><person id=“o123” mother=“o456”><name>John</name></person><person id=“o555”> <name> Jane </name> </person><person id=“o456”> <name> Mary </name> <children idref=“o123 o555”/></person><person id=“o123” mother=“o456”><name>John</name></person>oids and references in XML are just syntaxXML Semantics: a Tree !<data><person id=“o555” ><name> Mary </name><address><street> Maple </street> <no> 345 </no> <city> Seattle </city> </address></person><person><name> John </name><address> Thailand </address><phone> 23456 </phone></person></data><data><person id=“o555” ><name> Mary </name><address><street> Maple </street> <no> 345 </no> <city> Seattle </city> </address></person><person><name> John </name><address> Thailand </address><phone> 23456 </phone></person></data>dataMarypersonpersonnameaddressnameaddressstreet no cityMaple 345SeattleJohnThaiphone23456ido555ElementnodeTextnodeAttributenodeOrder matters !!!XML DataXML is self-describingSchema elements become part of the dataReational schema: persons(name,phone)In XML <persons>, <name>, <phone> are part of the data, and are repeated many timesConsequence: XML is much more flexibleXML = semistructured dataRelational Data as XML<person><row> <name>John</name> <phone> 3634</phone></row> <row> <name>Sue</name> <phone> 6343</phone> <row> <name>Dick</name> <phone> 6363</phone></row></person><person><row> <name>John</name> <phone> 3634</phone></row> <row> <name>Sue</name> <phone> 6343</phone> <row> <name>Dick</name> <phone> 6363</phone></row></person>n a m e p h o n eJ o h n 3 6 3 4S u e 6 3 4 3D i c k 6 3 6 3row row rowname name namephone phonephone“John” 3634 “Sue” “Dick”6343 6363personXML:personXML is Semi-structured DataMissing attributes:Could represent ina table with nulls <person> <name> John</name> <phone>1234</phone> </person><person> <name>Joe</name></person><person> <name> John</name> <phone>1234</phone> </person><person> <name>Joe</name></person> no phone !name phoneJohn 1234Joe -XML is Semi-structured DataRepeated attributesImpossible in tables:<person> <name> Mary</name> <phone>2345</phone> <phone>3456</phone></person><person> <name> Mary</name> <phone>2345</phone> <phone>3456</phone></person> two phones !name phoneMary 2345 3456???XML is Semi-structured DataAttributes with different types in different objectsNested collections (no 1NF)Heterogeneous collections:<db> contains both <book>s and <publisher>s<person> <name> <first> John </first> <last> Smith </last> </name> <phone>1234</phone></person><person> <name> <first> John </first> <last> Smith </last>
View Full Document