180 likes | 276 Views
What is XML ?. e X tensible M arkup L anguage A subset of SGML (Standard Generalized Markup Language) Mechanism to identify structures in a document Markup language for documents containing structured information Self-Descriptive Buzz Word. XML and HTML. Similar in nature <tags>
E N D
What is XML? • eXtensible Markup Language • A subset of SGML (Standard Generalized Markup Language) • Mechanism to identify structures in a document • Markup language for documents containing structured information • Self-Descriptive • Buzz Word
XML and HTML • Similar in nature • <tags> • Labels • Elements • <tags> plus content • Reference Specification • WWW consortium (W3C) • HTML transitional • XHTML • XML 1.0
XML Document Structure • Declaration • Elements • Attributes • Character Data • Processing Instructions • Comments • Entity References
Declaration <xml version=“1.0” encoding=“iso-8859-1”> • Start of the file • Optional • Future proof
Elements <Report> XML Report </Report> • Highest level termed as the root element • Contains: • Start tag • Some Content • End tag
Attributes <Report Author=“Stevie”> XML Report </Report> • Contains: • Name • Value
Character Data <Report Author=“Stevie”> <type>XML </type> Report </Report> • Element Content • Special Symbols • ‘&’ and ‘<‘ • See Entity References
Comments <!-- This is a Comment -->
Processing Instructions <?, and end with the string ?> • Show a processing instruction at the appropriate place in the node tree (DOM) • Firing a processing instruction event (SAX)
Well-Formed XML • Tags must be nested properly • All start tags must have end tags • Use quotation marks properly for tag attributes • Use entity references
Document Type Definition • Set of rules • May be included in the document itself • May be linked externally • Confirming to a DTD • Well-formed • valid
Document Type Definition * <!DOCTYPE rootElementName [ …insert declarations here… ]> * <!Element element (sub1, sub2,…,subn)> * <!ATTLIST element name (value1|value2)
XML Parsing • Document Object Model (DOM) • Simple API for XML (SAX)
Document Object Model (DOM) • Document Model driven • Build a tree model of the elements in the document • Allow for application to access the tree • DOM XML parser • Converts XML documents into Java Tree object model
Simple API for XML (SAX) • Event driven • SAX XML parser processes elements serially • XML application provides callback functions to handle elements
Freely Available XML Parsers • Apache Software Foundation Xerces XML Parser (xml.apache.org) • Open source • Oracle XML Parser Version 2 (www.oracle.com/xml) • Must register • SAX2 Parser (www.megginsion.com/SAX) • Freely available
References • http://www.w3.org/XML • http://www.xml.com • http://www.w3schools.com/xml/default.asp