Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.

Similar presentations


Presentation on theme: "What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data."— Presentation transcript:

1

2 What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.  Bridge for data exchange on the Web  XML tags are not predefined. You must define your own tags  XML is designed to be self-descriptive  XML is a W3C Recommendation

3 What is XML?  It is a protocol for containing and managing data. – A family of technologies:  Formatting documents to filtering data – A philosophy for handling information.  SGML ( Standard Generalized Markup Language) as defined by ISO 8879.  Not well suited for serving documents over the WEB.

4 What is XML?  XML is not a language itself. Rather, it’s a metalanguage used for writing other languages, called XML vocabularies.  XHTML is one of those vocabularies  XML is the most common tool for data transmissions between all sorts of applications.

5 Understanding XML Syntax  XML languages use tags to mark up text.  Here is an introduction to XML.  The above line is XHTML, but it’s also XML.  XML allows you to construct your own tags, so you could rewrite the previous markup as: Here is an introduction to XML.  In this example, the tag tells you the purpose of the text that it marks up.  One big advantage of XML is that tags can describe their content—that’s why XML languages are often called self- describing.  XML is flexible enough to allow for the creation of many different types of languages to describe data.  The only constraint on XML vocabularies is that they be well-formed.

6 Well-Formed Documents  XML documents are well-formed if they meet the following criteria: The document contains one or more elements. The document contains a single document element, which may contain other elements. Each element closes correctly. Elements are case-sensitive. Attribute values are enclosed in quotation marks and cannot be empty.

7 XML Document: Breakfast at Tiffany's Movie Classic Contact Movie Science fiction Little Britain TV Series Comedy

8 XML Document:  The document starts with an XML declaration:  This declaration is optional and can contain a number of attributes  This XML document also includes a comment describing its purpose:  The document or root element is called.  The document element contains a number of elements, and each element contains,, and elements. The element also contains an id attribute

9 Encoding  Encoding is the process of converting unicode characters into their equivalent binary representation. When the XML processor reads an XML document, it encodes the document depending on the type of encoding. Hence, we need to specify the type of encoding in the XML declaration.  Encoding Types  There are mainly two types of encoding:  UTF-8  UTF-16  UTF stands for UCS Transformation Format, and UCS itself means Universal Character Set. The number 8 or 16 refers to the number of bits used to represent a character. They are either 8(one byte) or 16(two bytes). For the documents without encoding information, UTF-8 is set by default.

10 Naming Rules in XML:  XML names cannot start with a number or punctuation.  XML names cannot include spaces.  Don’t include a colon in a name.  XML names are case-sensitive

11 Structure of an XML Document: Each XML document is divided into two parts:  Prolog:  Processing  Comments  DTD/Schema  Document:  Elements  Attribute  Text  CDATA  Entity  Comment

12 Valid XML Documents:  A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD) Students faculty Good Morning Hello Dear how are you Note: The DOCTYPE declaration in the example above, is a reference to an external DTD file.

13 Document Type Definition(DTD)  The Document Type Definition(DTD) describes a model of the structure of the content of an XML document. This model says what elements must be present, which ones are optional,what their attributes are and how they can be structured in relation to each other.  The DOCTYPE statement is the document type declaration. The DOCTYPE statement and the statements between the opening bracket and the closing bracket comprise the document type definition and define the rules of the document.

14 Internal DTD   <!DOCTYPE CATALOGS[   ]>   WEB TECHOLOGY  ………………….

15  External DTD   Save the above code as catdtd.dtd.

16   ………….  ….   ………

17 XML DTD Example: ]> The DTD above is interpreted like this:  !DOCTYPE note defines that the root element of this document is note  !ELEMENT note defines that the note element contains four elements: "to,from,heading,body"  !ELEMENT to defines the to element to be of type "#PCDATA"  !ELEMENT from defines the from element to be of type "#PCDATA"  !ELEMENT heading defines the heading element to be of type "#PCDATA"  !ELEMENT body defines the body element to be of type "#PCDATA“

18 XML Parser  An XML parser (also called XML processor) determines the content and structure of an XML document by combining an XML document and its DTD(if one is present).  XML Document+ XML DTD->XML Parser->XML application  XML parser is a software library or a package that provides interface for client applications to work with XML documents. It checks for proper format of the XML document and may also validate the XML documents.

19 XML Parser:  All modern browsers have a built-in XML parser  An XML parser converts an XML document into an XML DOM object  A DOM (Document Object Model) defines a standard way for accessing and manipulating documents. The XML DOM  The XML DOM defines a standard way for accessing and manipulating XML documents.  The XML DOM views an XML document as a tree-structure.  All elements can be accessed through the DOM tree. Their content (text and attributes) can be modified or deleted, and new elements can be created. The elements, their text, and their attributes are all known as nodes.

20 XML Namespaces  XML Namespaces provide a method to avoid element name conflicts.  When using prefixes in XML, a so- called namespace for the prefix must be defined.  The namespace is defined by the xmlns attribute in the start tag of an element.  The namespace declaration has the following syntax. xmlns:prefix="URL”.  The Namespace starts with the keyword xmlns.  The word name is the Namespace prefix.  The URL is the Namespace identifier.

21  Namespaces can be declared in the elements where they are used or in the XML root element:  Apples Bananas  ……..

22 XML Schema  XML Schema is commonly known as XML Schema Definition (XSD). It is used to describe and validate the structure and the content of XML data.  XML schema defines the elements, attributes and data types. Schema element supports Namespaces. It is similar to a database schema that describes the data in a database.  You need to declare a schema in your XML document as follows: 

23  Attributes in XSD provide extra information within an element. Attributes have name andtype property as shown below:   You can define XML schema elements in following ways:  Simple Type - Simple type element is used only in the context of the text. Some of predefined simple types are: xs:integer, xs:boolean, xs:string, xs:date.   Complex Type - A complex type is a container for other element definitions. This allows you to specify which child elements an element can contain and to provide some structure within your XML documents.

24


Download ppt "What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data."

Similar presentations


Ads by Google