Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1

2 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 in the right prospective. Some XML and document object model (DOM) details.

3 What XML is and what it is not? XML syntax is very similar to that of HTML, however: HTML deals with the format of a document XML deals with the content in the document. XML highlights what is to be displayed whereas HTML highlights how to display it. XML complements HTML. HTML document contains both the data as well as displaying instructions.XML contains only data. Example:

4 What XML is and what it is not? Both XML as well as HTML use tags however, the tags in HTML have fixed semantics and cannot mean anything different but the tags in XML can be assigned different meanings and additional tags can be created. XML makes the contents of a document readable not only by humans but also by machines. XML documents are text files and are therefore platform independent. HTML normally displays the entire contents of a document. with XML it is possible to select the information that is required to be displayed.

5 XML does not Do anything! It is just a way of structuring, storing and sending information. Format that can be understood by other applications. It facilitates exchange of data between incompatible systems (does not exchange data in itself). Developed by the W3C between 1996 and 1998 to provide a universal format for describing structured documents and data. XML describes a class of data objects called XML documents.

6 XML does not Do anything! It allows the creation of a markup language from scratch. Different industries and professions can develop custom languages that accurately handle their industry-specific data. Wireless Markup Language, Chemical Markup Language, Speech Synthesis Markup Language, Gene Expression Markup Language etc.. XML will provide greater flexibility in transferring data between different applications on different platforms and machines, and greatly increase the accuracy of web searches. Its reliance on Unicode makes it international.

7 Related Technologies XML Tags are created by programmers. How to tell a browser to display information inside a set of tags created by us? How do browsers display information contained in HTML tags? Standard predefined tags implemented by browser sftwr. We must therefore have some standard way to describe the tags created by us. We can then refer to this description and write programs to interpret / display the contents of the tags.

8 Related Technologies How to describe the tags and their properties? One of the techniques is called Document Type Definition (DTD). Does not use XML. Details later. Another more recent technique is Xmlschema. Uses XML How to display / interpret XML document? CSS (Cascaded Style Sheets) XSL (Extensible styling language) XSLT (Extensible styling language for transformations). DOM (Document object model) Details later. SAX (Simple API for XML).

9 Related Technologies XML Doc. DTD Xmlschema CSS, XSL XSLT, DOM TemplateDisplay / Interpret

10 Document Type Definition (DTD) A DTD is a set of rules that will be used by a parser that parses an XML document. It defines parts of a document and outlines how they can be used including their order and contents.It generally has: Processing instructions Entities Elements, including their start and end tags. Attributes Comments Character Data

11 Parts of DTD Processing Instructions. Most commonly used processing instructions are: Entities Variables used to define common text. Entity references are references to entities. Entities are expanded when a document is parsed by an XML parser. Reference to above :&COPYRIGHT Predefined entities: lt, gt, amp, quot, apos Referenced as: &lt ( ), &amp (&), &quot (“), &apos (‘).

12 Elements The main building blocks of an XML document are tagged elements like: ………. Element surrounded by angle brackets is called a ‘Tag’. Contents of an element go between a start-tag and end-tag. Syntax: Contents of an Element can be other Elements, (parent-child, sibling relationships) or PCDATA / CDATA / EMPTY /ANY. Example:

13 Elements Use of the elements declared in the previous slide: Today’s Memo Nov. 6, 2001 McMaster University I hope you like XML “DOC” is the parent of other elements that are siblings to each other.

14 Elements More Examples: Usage: any type of contents One or more elements Zero or more elements Zero or one elements Mixed Contents:

15 Attributes & Comments Provide extra information about elements, e.g.in HTML: XML attributes are declared as follows: <!ATLIST ARTICLE AUTHORS CDATA #REQUIRED EDITORS CDATA #IMPLIED> Comments: Same syntax as that in HTML

16 Syntax of XML XML syntax rules are simple and self-describing but strict. All XML documents must have a root element, called ‘document element’ and all children properly nested. …. All XML tags are case sensitive. All elements must be properly nested. All elements must have a closing tag.

17 Syntax of XML Attributes must be quoted. Element Names should follow the following rules: They can have letters, numbers and other characters They must not start with a number or punctuation characters They must not start with letters like: XML / Xml /xml They should not have spaces Avoid using hyphen or period in a name

18 “Well Formed” and “Valid” XML documents A Well Formed document is one that conforms to XML syntax A Valid document is a Well Formed document that also conforms to a DTD. Is this a Valid document? Is it Well Formed? How to refer to a DTD? Use processing instruction

19 External DTD and Internal DTD A DTD may be a part of an XML document – Internal Normally it is stored separately and can be referred as: We use:

20 Viewing XML Documents Internet Explorer 5+ can be used to view XML documents. XML source document is shown; Why? How can we view a formatted document? Using Cascaded Style Sheets CSS is one way. They specify how each tag in XML document being viewed must be formatted. Extensible Style Language (XSL). Not discussed here. CSS show the entire document just like HTML. What if we want to display only parts of a document?

21 Document Object Model (XMLDOM) XML document can be understood by other applications. It must be described in a way that other programming languages can manipulate its contents (add, delete, change). DOM is a programming interface for XML documents and exposes them as a tree structures in memory and provides an easy to use environment for the programmer. Look at earlier example: It can be shown as:

22 XML Tree Structure

23 XMLDOM DOM is a W3C recommendation. It specifies a language independent API that can be used with languages like Java, C++, Perl, Visual Basic or JavaScript and others. There are different implementations of DOM. We use Microsoft’s implementation. MS provides a parser in the form of a COM component in its IE5+. We use JavaScript to access it and to make different API calls. DOM uses three objects to access the XML file: Document, Node and Node List. Each has properties and methods. Common Node types are: Document Type, Processing Instruction, Element, Attribute, Text etc.

24 Example #1 Example1 Asghar Bokhari 9026568 A+

25 Example #2 Asghar Bokhari 9026568 28 29 38 A+

26 Example #3 K 600 Class Asghar Bokhari XML Lecture Please listen carefully Please read this memo Thank you very much

27 Example #4 <!DOCTYPE memo [ ]> K 600 Class Asghar Bokhari XML Lecture Please listen carefully Please read this memo Thank you very much


Download ppt "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."

Similar presentations


Ads by Google