xml for beginners ebook

28 271 0
xml for beginners ebook

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1 XML for beginners eXtensible Markup Language 2 Introduction and Motivation Dr. Praveen Madiraju Modified from Dr.Sagiv’s slides 3 XML vs. HTML • HTML is a HyperText Markup language – Designed for a specific application, namely, presenting and linking hypertext documents • XML describes structure and content (“semantics”) – The presentation is defined separately from the structure and the content 4 An Address Book as an XML document <addresses> <person> <name> Donald Duck</name> <tel> 414-222-1234 </tel> <email> donald@yahoo.com </email> </person> <person> <name> Miki Mouse</name> <tel> 123-456-7890 </tel> <email>miki@yahoo.com</email> </person> </addresses> 5 Main Features of XML • No fixed set of tags – New tags can be added for new applications • An agreed upon set of tags can be used in many applications – Namespaces facilitate uniform and coherent descriptions of data • For example, a namespace for address books determines whether to use <tel> or <phone> 6 Main Features of XML (cont’d) • XML has the concept of a schema – DTD and the more expressive XML Schema • XML is a data model – Similar to the semistructured data model • XML supports internationalization ( Unicode) and platform independence (an XML file is just a character file) 7 XML is the Standard for Data Exchange • Web services (e.g., ecommerce) require exchanging data between various applications that run on different platforms • XML (augmented with namespaces) is the preferred syntax for data exchange on the Web 8 XML is not Alone • XML Schemas strengthen the data-modeling capabilities of XML (in comparison to XML with only DTDs) • XPath is a language for accessing parts of XML documents • XLink and XPointer support cross-references • XSLT is a language for transforming XML documents into other XML documents (including XHTML, for displaying XML files) – Limited styling of XML can be done with CSS alone • XQuery is a lanaguage for querying XML documents 9 The Two Facets of XML • Some XML files are just text documents with tags that denote their structure and include some metadata (e.g., an attribute that gives the name of the person who did the proofreading) – See an example on the next slide – XML is a subset of SGML (Standard Generalized Markup Language) • Other XML documents are similar to database files (e.g., an address book) 10 XML can Describe the Structure of a Document • <book year="1994"> <title>TCP/IP Illustrated</title> <author> <last>Stevens</last> <first>W.</first> </author> <publisher>Addison-Wesley</publisher> <price>65.95</price> </book> [...]... reference guide for acceptable breeds Your entry should look something like this: Sir Fredrick of Ledyard's End]]> 23 A Complete XML Document http://www.mscs.mu.edu/~praveen/Teachi ng/fa05/AdvDb/Lectures/bib .xml 24 Well-Formed XML Documents • An XML document (with or without a DTD) is well-formed if – Tags.. .XML Syntax W3Schools Resources on XML Syntax 11 The Structure of XML • XML consists of tags and text • Tags come in pairs • They must be properly nested – good – bad (You can’t do in HTML) 12 A Useful Abbreviation Abbreviating elements with empty contents: • for • for. .. text • XML text is called PCDATA – (for parsed character data) • It uses a 16-bit encoding, e.g., \&\#x0152 for the Hebrew letter Mem 14 XML Structure • Nesting tags can be used to express various structures, e.g., a tuple (record): Lisa Simpson 02-828-1234 054-470-777 lisa@cs.huji.ac.il 15 XML Structure (cont’d) • We can represent... width=“10”> For example: Lisa Simpson Note that a tag may have a set of attributes, each consisting of a name and a value 13 XML Text XML has only one “basic” type – text It is bounded by tags, e.g., The Big Sleep 1935 – 1935 is still text • XML text is... properly nested – There is a root tag An XML document must be well formed – A start tag does not have two occurrences of the same attribute 25 Representing relational databases A relational database for school: student: course: id name gpa 001 002 … Joe Mary … 3.0 4.0 … id enroll: 331 350 331 … title credit 331 350 … DB Web … 3.0 3.0 … cno 001 001 002 … cno 26 XML representation ... encoding="UTF-8"?> – Standalone=“no” means that there is an external DTD – You can leave out the encoding attribute and the processor will use the UTF-8 default 21 Processing Instructions < ?xml version="1.0"?> < ?xml- stylesheet href="doc.xsl" type="text/xsl"?> Hello, world! 22 Using CDATA... … … … 16 XML Structure (cont’d) Donald Duck 04-828-1345 donald@cs.technion.ac.il Miki Mouse 03-426-1142 miki@yahoo.com 17 Terminology The segment of an XML document between an opening and a corresponding closing... not an element 18 An XML Document is a Tree person name tel tel email Bart Simpson 051 – 011 022 02 – 444 7777 bart@tau.ac.il Leaves are either empty or contain PCDATA 19 Mixed Content An element may contain a mixture of subelements and PCDATA British Airways World’s favorite airline 20 The Header Tag • < ?xml version="1.0" standalone="yes/no"... id=“002”> Mary 4.0 DB 3.0 3.0 Web 27 XML representation 001 001 002 331 350 331 28 . parts of XML documents • XLink and XPointer support cross-references • XSLT is a language for transforming XML documents into other XML documents (including XHTML, for displaying XML files) – Limited. preferred syntax for data exchange on the Web 8 XML is not Alone • XML Schemas strengthen the data-modeling capabilities of XML (in comparison to XML with only DTDs) • XPath is a language for accessing. the more expressive XML Schema • XML is a data model – Similar to the semistructured data model • XML supports internationalization ( Unicode) and platform independence (an XML file is just a

Ngày đăng: 23/10/2014, 17:17

Mục lục

  • XML for beginners

  • Introduction and Motivation

  • XML vs. HTML

  • An Address Book as an XML document

  • Main Features of XML

  • Main Features of XML (cont’d)

  • XML is the Standard for Data Exchange

  • XML is not Alone

  • The Two Facets of XML

  • XML can Describe the Structure of a Document

  • XML Syntax

  • The Structure of XML

  • A Useful Abbreviation

  • XML Text

  • XML Structure

  • XML Structure (cont’d)

  • Slide 17

  • Terminology

  • An XML Document is a Tree

  • Mixed Content

Tài liệu cùng người dùng

Tài liệu liên quan