1 / 104

XML

XML. Markup Language. Markup refers to anything put on a document which adds some special meaning or provides some extra information. Markup can be classified into three types 1. Stylistic Markup ( <font> <I> <B> .. ) 2. Structural Markup ( <H1><P><DIV> …)

salaam
Download Presentation

XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML

  2. Markup Language Markup refers to anything put on a document which adds some special meaning or provides some extra information. Markup can be classified into three types 1. Stylistic Markup ( <font> <I> <B> .. ) 2. Structural Markup ( <H1><P><DIV> …) 3. Semantic Markup ( <TITLE> <META>..)

  3. SGML Sgml is the first mark up language. It’s a powerful markup language but it is very complicated .

  4. HTML & IT’s DRAWBACKS 1. HTML has a fixed tag set. 2. HTML is a presentation technology. 3. HTML is flat.( No Hierarchy) 4. High Traffic Volumes.

  5. XML XML is the Extensible Markup Language which is designed to enable the use of SGML on the World Wide Web. XML is not a single predefined markup language : it’s a metalanguage - a language for describing other languages .

  6. Advantages of XML 1. XML separates data and display 2. Create custom tags that relate to the content. 3. View the same data in different ways. 4. Less Traffic Volumes.

  7. Converting HTML to XML

  8. <HTML> <BODY><CENTER> <Table Border=“2”> <TH> BookName</TH> <TH> Author </TH> <TR><TD> Securing Java </TD><TD> Gary Mc. Graw. Edward W.Felten </TD></TR> ……… </Table></CENTER> </BODY> </HTML>

  9. <Library> <Book>Securing Java</Book> <Author>Gary Mc. Graw. </Author> <Book>Software Engineering</Book> <Author>Roger S. </Author> <Book>Java Virtual Machine</Book> <Author>Bill Venners</Author> ….. …… </Library>

  10. SYNTACTIC DIFFERENCE

  11. Every start tag should have a corresponding end tag. <element1> <element2> <element3> </element3> </element2> </element1>

  12. Elements cannot Overlap Invalid <element1> <element2> <element3> </element2> </element3> </element1> Valid <element1> <element2> <element3> </element3> </element2> </element1>

  13. <element1 type=“top”> <element2 type=“left”> <element3> </element3> </element2> </element1> All Attributes should be in Quotes

  14. XML is case sensitive <element1 type=“top”> <Element1 type=“left”> <ELEMENT1> </ELEMENT1> </Element1> </element1>

  15. Uses of XML 1. E-Commerce Applications 2. Create Other Markup Languages 3. Push - Technology 4. Advanced Search Engines.

  16. XML SYSTEM

  17. A XML system typically consists of the following. 1. XML Document ( Content ) 2. XML Document Type Definition ( DTD ) 3. XML Parser ( Conformity Checker ) 4. XML Application .

  18. XML TYPES * Well Formed Documents. * Valid Documents

  19. XML Document contains five classes of elements in it they are, 1. ELEMENTS 2. ENTITIES 3. COMMENTS 4. Processing Instructions 5. CDATA Sections XML Document

  20. ELEMENTS XML document is made up of elements . Elements are made up of Start-Tag , content and a End Tag. <mytag> My First XML Tag</mytag> Start- Tag Character Data End- Tag ELEMENT

  21. ENTITIES Entities are same as the #define statements. <!ENTITY entityname “some replacement text”> To refer a entity &entityname;

  22. COMMENTS COMMENTS TAKE THE FOLLOWING GENERAL FORM <!-- A Comment --> Note: The String “--” is not allowed to occur within a comment

  23.  <!-- This is perfectly a legal comment spanning two lines --> <!-- Not Legal Comment <!-- Iam Inner --> Iam Outer--> Comment Examples

  24. Processing Instructions Processing instructions (PIs) allow documents to contain instructions for applications. PIs are not part of the document's character data. SYNTAX <?NameofTargetApp Instructions for App?>

  25. PI Examples • <?xml version=“1.0”?> • <?xml-stylesheet href=“student.xsl”?>

  26. CDATA Sections A CDATA section is used in XML to shield a body of text from the attention of the XML processor. The first occurrence of “]]>” will terminate the CDATA section. CDATA sections cannot be nested. SYNTAX <![CDATA[ …………. ]]>

  27. CDATA Section Example <Subject name=“HTML”> <Syntax> <![CDATA[ <HTML> <HEAD> <BODY> Hello World </BODY> </HEAD> </HTML> ]]> </Syntax> </Subject> IGNORED

  28. XML DOCUMENT PROLOG DOCUMENT TYPE DECLARATION ROOT ELEMENT

  29. A Prolog is everything that occurs before the root element starts. PROLOG COMMENTS PROCESSING INSTRUCTIONS

  30. The Document Type Declaration is used to declare elements, entities, attributes and so on. (optional) ELEMENT DECL ENTITY DECL NOTATION DECL PROCESSING INSTRUCTIONS ATTRIBUTE DECL COMMENTS ENTITY REFS (Parameter entities)

  31. The root element of an XML document is the element that contains all other elements in the document. The root element can be empty.(Not a useful XML document ) COMMENTS EMPTY ELEMENTS ELEMENTS PROCESSING INSTRUCTIONS ENTITY REFS (Not Parameter entities) CDATA SECTIONS

  32. XML Parser Parser is an application that Validates an XML Document. There are two kinds of Parsers . Validating Parser. Non-Validating Parser.

  33. Validating Parser Document Valid XML Parser Structure Rules (DTD) Invalid XML

  34. Non Validating Parser Well Formed Document Parser Not Well Formed

  35. DTD

  36. Document Type Declaration • The Document Type Declaration can have the definitions either as an Internal Subset External Subset SYNTAX <!DOCTYPE …..>

  37. Internal Subset <!DOCTYPE …..[ <!-- Internal Subset --> ]>

  38. Sample.xml <!DOCTYPE Students [ <!ELEMENT Students (Student)> <!ELEMENT Student ( Name,Age ) > <!ELEMENT Name (#PCDATA)> <!ELEMENT Age (#PCDATA)> ]> <Students> <Student> <Name>Ravi</Name> <Age>25</Age> </Student> </Students>

  39. External Subset <!DOCTYPE ROOT SYSTEM “…”> Example <!DOCTYPE Students SYSTEM “Student.dtd”> Student.dtd ( a separate file ) <!ELEMENT Students (Student +)> <!ELEMENT Student (Name,Age)>

  40. Document with both Internal &External Subsets <!DOCTYPE Root SYSTEM “Sample.dtd” [ ……. ]>

  41. <!DOCTYPE Students SYSTEM “Address.dtd”[ <!ELEMENT Student ( Name,Age ,Address) > <!ELEMENT Name (#PCDATA)> <!ELEMENT Age (#PCDATA)> ]> <Students> <Student> <Name>Ravi</Name> <Age>25</Age> <Address> <DoorNo>..</DoorNo> <Street>..</Street> <City>..</City> <PinCode>..</PinCode> </Address> </Student> </Students>

  42. Address.dtd <!ELEMENT Address (DoorNo,Street,City,PinCode)> <!ELEMENT DoorNo (#PCDATA)> <!ELEMENT Street (#PCDATA)> <!ELEMENT City (#PCDATA)> <!ELEMENT PinCode (#PCDATA)>

  43. Element Type declarations Elements can contain other elements or character data. SYNTAX <!ELEMENT elmt_name content_spec> <!ELEMENT elmt_name (content_model) >

  44. Content Specification • EMPTY • ANY

  45. If the content of an element is not textual at all than the EMPTY keyword can be used to define the element. Example <!ELEMENT IMG EMPTY> <IMG/> (or) <IMG></IMG>

  46. An element declared as ANY can contain any mixture of character - data and other elements as long as the elements have been declared in the DTD. Example <!ELEMENT BODY ANY> <BODY> <BODY> <BODY> some Text<elements><elements> </BODY> </BODY> some text </BODY>

  47. <!ELEMENT Name ANY> <Name> <Fname>..</Fname> <Sname>..</Sname> </Name> OR <Name>..</Name>

  48. Sample.xml <! DOCTYPE Students [ <!ELEMENT Student ( Name,Age ) > <!ELEMENT Name (#PCDATA)> <!ELEMENT Age (#PCDATA)> ]> <Students> <Student> <Name>Ravi</Name> <Age>25</Age> </Student> </Students>

More Related