Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Overview XML crash course –HTML vs. XML –pure XML data model (XML = linear syntax for trees) XML Schema Rubin Landau, Bertram Ludaescher, Richard Marciano,

Similar presentations


Presentation on theme: "1 Overview XML crash course –HTML vs. XML –pure XML data model (XML = linear syntax for trees) XML Schema Rubin Landau, Bertram Ludaescher, Richard Marciano,"— Presentation transcript:

1 1 Overview XML crash course –HTML vs. XML –pure XML data model (XML = linear syntax for trees) XML Schema Rubin Landau, Bertram Ludaescher, Richard Marciano, rubin@physics.orst.edu {ludaesch,marciano}@sdsc.edu

2 2 XML (eXtensible Markup Language) origins: HTML + SGML (ISO Standard, 1986, ~600pp) W3C standard (~26 pp): XML syntax + DTDs XML = HTML  presentational tags + user-defined DTD (tags+nesting) => a metalanguage for defining other languages via DTDs => XML is more like SGML than HTML XML = SGML  {complexity, document perspective} + {simplicity, data exchange perspective}

3 3 Some History (or: from fat via lean… SGML (Standard Generalized Markup Language) –ISO Standard, 1986, for data storage & exchange –Metalanguage for defining languages (through DTDs) –A famous SGML language: HTML!! –Separation of content and display –Used in U.S. gvt. & contractors, large manufacturing companies, technical info. Publishers,... –SGML reference is 600 pages long XML (eXtensible Markup Language) –W3C (World Wide Web Consortium) -- http://www.w3.org/XML/ recommendation in 1998W3Chttp://www.w3.org/XML/ –Simple subset (80/20 rule) of SGML: “ASCII of the Web”, “Semantic Web” –XML specification is 26 pages long

4 4 HTML Bibliography Foundations of DBs, Abiteboul, Hull, Vianu Addison-Wesley, 1995 Logics for DBs and ISs, Chomicki, Saake, eds. Kluwer, 1998 HTML tags: presentation aspects, generic document structure Bibliography Foundations of DBs, Abiteboul, Hull, Vianu Addison-Wesley, 1995 Logics for DBs and ISs, Chomicki, Saake, eds. Kluwer, 1998

5 5 HTML vs. XML Bibliography Foundations of DBs, Abiteboul, Hull, Vianu Addison-Wesley, 1995 Logics for DBs and ISs, Chomicki, Saake, eds. Kluwer, 1998 Foundations of DBs Abiteboul Hull Vianu Addison-Wesley....... Chomicki...... XML tags: content, "semantic", (DTD-) specific HTML tags: presentation aspects, generic document structure

6 6 Elements and their Content element type character content element empty element Y.Papakonstantinou S. Abiteboul H. Garcia-Molina Object Fusion in Mediator Systems VLDB 96 element content

7 7 Element Attributes Y.Papakonstantinou S. Abiteboul H. Garcia-Molina Object Fusion in Mediator Systems VLDB 96 Attribute name Attribute Value

8 8 Pure XML -- Instance Model XML 1.0 Standard: –no explicit data model –only syntax of well-formed and valid (wrt. a DTD) documents implicit data model: –nested containers ("boxes within boxes") –labeled ordered trees (=a semistructured data model) –relational, object-oriented, other data: easy to encode foo bar lab A B C "foo" "bar" C: "bar" A: B: "foo" C: "lab" C children are ordered

9 9 Example: Relational Data to XML ABC a1b1c1 a2b2c2 a3b3c3 R  R   tuple   A  a1  /A   B  b1  /B   C  c1  /C   /tuple   tuple   A  a2  /A   B  b2  /B   C  c2  /C   /tuple  …  /R  R tuple ABC a1 b1 c1 tuple ABC a2 b2 c2 tuple ABC a3 b3 c3

10 10 Extending DTDs: Data Modeling Approaches XML main stream: XML Schema –data types –user defined types, type extensions/restrictions ("subclassing") –cardinality constraints XML side streams: –RELAX (REgular Language description for XML), SOX (Schema for Object-Oriented XML), Schematron,... alternative approach: –use well-established data modeling formalisms like (E)ER, UML, ORM, OO models,...... and just encode them in XML! –e.g. UML: XMI (standardized, has much more=>big), UXF (UML eXchange Format)

11 11 From Documents to Data: XML Schema XML DTDs (part of the XML spec.) –flexible, semistructured data model (nesting, ANY, ?, *, |,...) –but document-oriented (SGML heritage) –no support for namespaces, datatypes, inheritance (e.g., type of book.title may be different from poem.title) XML Schema (W3C working draft) –schema definition language in XML –data-oriented: data types –extends capabilities of DTD

12 12 From Documents to Data: Example 1999-01-21 1999-01-25 Ashok Malhotra 123 IBM Ave. Hawthorne NY 10532-0000 555-1234 555-4321 Paul V. Biron Ashok Malhotra Latest draft We need to discuss the latest draft immediately. Either email me at mailto:paul.v.biron@kp.org or call 555-9876 Document-Oriented: Data-Oriented:

13 13 XML Schema W3C Working Draft, September 2000 Primer:Primer –introduction to the basic ideas Structures: –Specify complex element structure and –Set constraints on the permitted values of the content of those elements Datatypes: –Sets forth a standard of content datatypes and –Sets rules for generating new types from them

14 14 XML Schema: Example

15 15 XML Schema: Example... <xsd:attribute name="country" type="xsd:NMTOKEN" use="fixed" value="US"/>

16 16 XML Schema: Example New types can be derived by extension or restriction:

17 17 Presenting XML: Extensible Stylesheet Language -- Transformations (XSLT) Why Stylesheets? –separation of content (XML) from presentation (XSLT) Why not just CSS for XML? –XSL is far more powerful: selecting elements transforming the XML tree content based display (result may depend on actual data values)

18 18 XSL(T) Overview XSL stylesheets are denoted in XML syntax XSL components: 1. a language for transforming XML documents (XSLT: integral part of the XSL specification) 2. an XML formatting vocabulary (Formatting Objects: >90% of the formatting properties inherited from CSS)

19 19 XSLT Processing Model XML source tree XML,HTML,csv, text… result tree XSLT stylesheet Transformation

20 20 XSLT Elements –root element of an XSLT stylesheet "program"...template... –declares a rule: (pattern => template) –apply templates to selected children (default=all) –optional mode attribute

21 21 XSLT Processing Model XSL stylesheet: collection of template rules template rule: (pattern  template) main steps: –match pattern against source tree –instantiate template (replace current node “.” by the template in the result tree) –select further nodes for processing control can be a mix of –recursive processing ("push":...) –program-driven ("pull":...)

22 22 Template Rule: Example (i) match pattern: process elements (ii) instantiate template: replace each product element with two HTML tables (iii) select the grandchildren (“sales/domestic”, “sales/foreign”) for further processing pattern template

23 23 XSLT Example

24 24 XSLT Example (cont’d)

25 25 XSLT Example (cont’d)

26 26 Creating the Result Tree... Literal result elements: non-XSL elements (e.g., HTML) appear “literally” in the result tree Constructing elements: (similar for xsl:attribute, xsl:text, xsl:comment,…) Generating text: attribute & children definition


Download ppt "1 Overview XML crash course –HTML vs. XML –pure XML data model (XML = linear syntax for trees) XML Schema Rubin Landau, Bertram Ludaescher, Richard Marciano,"

Similar presentations


Ads by Google