Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li.

Similar presentations


Presentation on theme: "XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li."— Presentation transcript:

1 XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li

2 W3SCHOOLS.COM a very nice material is found at http://www.w3schools.com/xml/xml_syntax.asp 2

3 3 XML vs. HTML HTML is a HyperText Markup language o Designed for a specific application, namely, presenting and linking hypertext documents XML describes structure and content (“semantics”) o The presentation is defined separately from the structure and the content

4 4 An Address Book as an XML document Donald Duck 414-222-1234 donald@yahoo.com Miki Mouse 123-456-7890 miki@yahoo.com

5 5 Main Features of XML No fixed set of tags o New tags can be added for new applications An agreed upon set of tags can be used in many applications o Namespaces facilitate uniform and coherent descriptions of data  For example, a namespace for address books determines whether to use or

6 6 Main Features of XML (cont’d) XML has the concept of a schema o DTD and the more expressive XML Schema XML is a data model o Similar to the semistructured data model o cf. DB Schema XML supports internationalization (Unicode) and platform independence (an XML file is just a character file)Unicode

7 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 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) o Limited styling of XML can be done with CSS alone XQuery is a lanaguage for querying XML documents

9 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) o See an example on the next slide o XML is a subset of SGML (Standard Generalized Markup Language) Other XML documents are similar to database files (e.g., an address book)

10 10 XML can Describe the Structure of a Document TCP/IP Illustrated Stevens W. Addison-Wesley 65.95

11 11 XML Syntax W3Schools Resources on XML Syntax

12 12 The Structure of XML XML consists of tags and text Tags come in pairs... They must be properly nested o good......... o bad......... (You can’t do......... in HTML)

13 13 A Useful Abbreviation Abbreviating elements with empty contents: for For example: Lisa Simpson... Note that a tag may have a set of attributes, each consisting of a name and a value

14 14 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 called PCDATA o (for parsed character data)

15 15 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

16 16 XML Structure (cont’d) We can represent a list by using the same tag repeatedly: …

17 17 XML Structure (cont’d) Donald Duck 04-828-1345 donald@cs.technion.ac.il Miki Mouse 03-426-1142 miki@yahoo.com

18 18 Terminology The segment of an XML document between an opening and a corresponding closing tag is called an element Bart Simpson 02 – 444 7777 051 – 011 022 bart@tau.ac.il element element, a sub-element of

19 19 An XML Document is a Tree person name email tel Bart Simpson 02 – 444 7777 051 – 011 022 bart@tau.ac.il Leaves are either empty or contain PCDATA

20 20 Mixed Content An element may contain a mixture of sub-elements and PCDATA British Airways World’s favorite airline

21 XML Attributes XML elements can have attributes, just like HTML: o Attributes are designed to contain data related to a specific element. o Must be quoted Example Attributes vs. Elements: Example female To consider o attributes cannot contain multiple values (elements can) o attributes cannot contain tree structures (elements can) o attributes are not easily expandable (for future changes) 21

22 XML Attributes as Metadata 22 Tove Jani Reminder Don't forget me this weekend! Jani Tove Re: Reminder I will not

23 XML Namespaces Apples Bananas African Table 80 120  leads to a conflict 23 Apples Bananas African Coffee 80 120 Using a Prefix

24 24 The Header Tag o Standalone=“no” means that there is an external DTD o You can leave out the encoding attribute and the processor will use the UTF-8 default

25 25 Processing Instructions Hello, world!

26 26 Well-Formed XML Documents An XML document (with or without a DTD) is well- formed if o Tags are syntactically correct o Every tag has an end tag o Tags are properly nested o There is a root tag o A start tag does not have two occurrences of the same attribute An XML document must be well formed

27 27 Representing relational databases A relational database for school: student:course: enroll:

28 28 XML representation of relational DB Joe 3.0 Mary 4.0 DB 3.0 Web 3.0 001 331 001 350 002 331


Download ppt "XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li."

Similar presentations


Ads by Google