18
What is What is XML XML ? ? e e X X tensible tensible M M arkup arkup L L anguage anguage A subset of SGML (Standard A subset of SGML (Standard Generalized Markup Language) Generalized Markup Language) Mechanism to identify structures in a Mechanism to identify structures in a document document Markup language for documents Markup language for documents containing structured information containing structured information Self-Descriptive Self-Descriptive Buzz Word Buzz Word

What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Embed Size (px)

Citation preview

Page 1: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

What is What is XMLXML??

eeXXtensible tensible MMarkup arkup LLanguageanguage A subset of SGML (Standard A subset of SGML (Standard

Generalized Markup Language)Generalized Markup Language) Mechanism to identify structures in a Mechanism to identify structures in a

documentdocument Markup language for documents Markup language for documents

containing structured informationcontaining structured information Self-DescriptiveSelf-Descriptive Buzz WordBuzz Word

Page 2: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

XML and HTMLXML and HTML Similar in natureSimilar in nature <tags> <tags>

LabelsLabels ElementsElements

<tags> plus <tags> plus contentcontent Reference SpecificationReference Specification

WWW consortium (W3C)WWW consortium (W3C) HTML transitionalHTML transitional XHTMLXHTML XML 1.0XML 1.0

Page 3: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

XML Document XML Document StructureStructure

DeclarationDeclaration ElementsElements AttributesAttributes Character DataCharacter Data Processing InstructionsProcessing Instructions CommentsComments Entity ReferencesEntity References

Page 4: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

DeclarationDeclaration

<xml version=“1.0” encoding=“iso-8859-<xml version=“1.0” encoding=“iso-8859-1”>1”>

Start of the fileStart of the file OptionalOptional Future proofFuture proof

Page 5: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

ElementsElements

<Report><Report>XML ReportXML Report

</Report></Report> Highest level termed as the root Highest level termed as the root

elementelement Contains:Contains:

Start tagStart tag Some ContentSome Content End tagEnd tag

Page 6: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

AttributesAttributes

<Report <Report Author=“Stevie”Author=“Stevie”>>

XML ReportXML Report

</Report></Report> Contains:Contains:

NameName ValueValue

Page 7: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Character DataCharacter Data

<Report Author=“Stevie”><Report Author=“Stevie”>

<type>XML </type> Report<type>XML </type> Report

</Report></Report> Element ContentElement Content Special SymbolsSpecial Symbols

‘‘&’ and ‘<‘&’ and ‘<‘ See Entity ReferencesSee Entity References

Page 8: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

CommentsComments

<!-- This is a Comment --><!-- This is a Comment -->

Page 9: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Entity ReferencesEntity References

EntityEntity CharacterCharacter

&lt;&lt; <<

&gt;&gt; >>

&amp;&amp; &&

&apos;&apos; ‘‘

&quot;&quot; ““

Page 10: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Processing InstructionsProcessing Instructions

<?, <?, and end with the stringand end with the string ?> ?> Show a processing instruction at the Show a processing instruction at the

appropriate place in the node tree appropriate place in the node tree (DOM)(DOM)

Firing a processing instruction event Firing a processing instruction event (SAX)(SAX)

Page 11: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Well-Formed XMLWell-Formed XML

Tags must be nested properlyTags must be nested properly All start tags must have end tagsAll start tags must have end tags Use quotation marks properly for Use quotation marks properly for

tag attributestag attributes Use entity referencesUse entity references

Page 12: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Document Type Document Type DefinitionDefinition

Set of rulesSet of rules May be included in the document May be included in the document

itselfitself May be linked externallyMay be linked externally Confirming to a DTDConfirming to a DTD

Well-formedWell-formed validvalid

Page 13: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Document Type Document Type DefinitionDefinition

** <!DOCTYPE rootElementName [<!DOCTYPE rootElementName [

……insert declarations here…insert declarations here…

]>]>

** <!Element <!Element element element ((sub1sub1, , sub2sub2,,…,…,subnsubn)>)>

** <!ATTLIST <!ATTLIST element name (value1|element name (value1|value2)value2)

Page 14: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

XML ParsingXML Parsing

Document Object Model (DOM)Document Object Model (DOM) Simple API for XML (SAX)Simple API for XML (SAX)

Page 15: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Document Object Model Document Object Model ((DOMDOM))

Document Model drivenDocument Model driven Build a tree model of the elements in Build a tree model of the elements in

the documentthe document Allow for application to access the Allow for application to access the

treetree DOM XML parserDOM XML parser

Converts XML documents into Java Tree Converts XML documents into Java Tree object modelobject model

Page 16: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Simple API for XML Simple API for XML ((SAXSAX))

Event drivenEvent driven SAX XML parser processes elements SAX XML parser processes elements

seriallyserially XML application provides callback XML application provides callback

functions to handle elementsfunctions to handle elements

Page 17: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

Freely Available XML Freely Available XML ParsersParsers

Apache Software Foundation Xerces Apache Software Foundation Xerces XML Parser (XML Parser (xml.apache.orgxml.apache.org)) Open sourceOpen source

Oracle XML Parser Version 2 (Oracle XML Parser Version 2 (www.oracle.com/xmlwww.oracle.com/xml)) Must registerMust register

SAX2 Parser (SAX2 Parser (www.megginsion.com/SAXwww.megginsion.com/SAX)) Freely availableFreely available

Page 18: What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized

ReferencesReferences

http://www.w3.org/XMLhttp://www.w3.org/XML http://www.xml.comhttp://www.xml.com http://www.w3schools.com/xml/http://www.w3schools.com/xml/

default.aspdefault.asp