XML by Jon Pearce
What is XML? XML = eXstensible Markup Language = a meta language for defining markup languages. Examples: MathML, SVG (Scalable Vector Graphics), WML (Wireless Markup Language), XBRL (Extensible Business Reporting Language), XUL (Extensible User Interface Language), PDML (Product Data Markul Language), CML (Chemical ML), VoiceXML, VML (Vector ML), cXML (Commerce XML), tpaML (Traqding partner agreement XML), SMBXML (Small to Medium Business XML), FinXML (Financial XML), SOAP, XHTML, OWL
XML History Standard Generalized Markup Language –Invented in 1980s for publishing industry –Markup meta language –HTML is an SGML language –Ancestor of XML
Uses of XML Data Storage –Object Serialization –Presentation Independent –Language Independent Application Initialization Message Passing –Between Tiers Data-Business-Presentation-Client –SOAP and Web Services
An XML Document Contains: A Prolog Elements content Comments CDATA Sections Processing Instructions (PIs)
Format of an XML Document ELEMENT ELEMENT...
Tree Structure of an XML Document
A Document Prolog Contains: XML Declaration DTD (optional) Style Sheet (optional) etc.
An XML Element Contains: content 09/01/2002 An empty element:
Example: book.xml PERSON PERSON PERSON...
A Person Element (1) NAME ADDRESS PHONE
A Person Element (2) Joe Smith 123 Sesame St New York NY (555)
Displaying XML in IE
Grammars G = a grammar L(G) = Language defined by G w L(G) means w is a valid L(G) sentence Example: –G = English grammar –G = Java grammar
Grammar Rules An EBNF grammar is a list of rules of the form: –PARENT ::= CHILDREN CHILDREN is a regular expression: –A B, A | B, A*, A?, 'leaf'
Addresses EBNF ADDRESSES ::= PERSON* PERSON ::= NAME ADDRESS PHONE NAME ::= FIRST LAST ADDRESS ::= STREET CITY STATE PHONE, FIRST, LAST, STREET, CITY, STATE ::= STRING
addresses.dtd
book.xml (with a dtd) PERSON PERSON PERSON...
Well Formed vs. Valid Documents Validating Parsers determine if an XML document conforms to its DTD Non-validating parsers merely determine if an xml document is well formed
Extensible Style Sheet Language XSL is an XML language for describing a transformation An XSL document describes a transformation that transforms XML documents into xHTML documents
XSL Format HTML + XML instructions
XSL Markup... –selects each element in an XML document matching TAG and performs... –Displays the value of TAG
addresses.xsl Addresses Here are your addresses: name = phone =
book.xml (with an xsl) PERSON PERSON PERSON...
Displaying book.xml in IE (2)