XML

Introduction: Extensible Markup Language (XML)
The basic outline for these notes is based on a presentation by Daniel Rutten, from Clockwise Smart Software Solutions, to the Napier, (New Zealand) Microsoft Dot net user group in 2009.Based on a presentation by Daniel Rutten (2009).

Basic XML file
Note how &lt;comment> is not mandatory

XML and Related Technologies

 * XML, XHTML, XML DOM,
 * XSL, XSLT
 * XPath, XSL-FO, XLink, XPointer, DTD
 * XSD, XForms, XQuery, SOAP, WSDL
 * RDF, RSS, WAP, SMIL, SVG

SGML

 * 1960’s
 * Standard Generalized Markup Language
 * Manage large documents
 * Subject to frequent revisions
 * Printed in different formats
 * Specifies rules for tagging elements
 * SGML ISO-8879, 1986

XML

 * Derived from SGML
 * eXtensible Markup Language
 * Easier to implement but less flexible
 * No need for a Document Type Definition
 * W3C Recommendation in 1998

EXI (Efficient XML Interchange)
The World Wide Web Consortium (W3C) has issued a standard for a compact form of XML for use on smartphones and devices with memory or bandwidth constraints. The Efficient XML Interchange (EXI) standard will reduce XML processing's demands for network utilization, power, and energy. Work is already underway to support the standard for the compact representation of XML information in development toolkits. "[EXI is] an optimization of the XML exchange," says John Schneider, editor of the EXI specification. EXI could be used in sensor networks, cameras, automobiles, real-time trading systems, and wireless phones. "Even though [XML is] used everywhere, it's not used in some places because [of] constraints like giant documents or battery consumption or limited bandwidth," says W3C's Liam Quin. EXI could potentially displace XML at some user sites, say W3C officials. (Krill, 2011, March 10)

HTML versus XML

 * HTML
 * Designed to display data
 * Focus on how data looks
 * Fixed tag set and semantics
 * XML
 * Designed to describe data
 * Focus on what data is
 * Extensible(!) tag set and semantics

Six golden rules of XML
1. All XML documents begin with

2. All XML documents must have one(and only one) root element

3. All XML elements must have a closing tag

4. XML tags are case sensitive

5. All XML elements must be properly nested

6. Attribute values must always be quoted

Well-formed versus Valid

 * A "Well Formed" XML document has correct XML syntax
 * A "Valid" XML document also conforms to a DTD or XSD

Some features

 * Comments


 * Adding data that is not to be parsed (e.g. inserting HTML into an XML file


 * White space


 * Namespaces: Allow you to cope with merging two XML files which have the same tags but for different purposes (e.g. Merging a Staff file with a student file.


 * Escape Characters

sample.xml
If we create an XML file as

sample.css
We can build a CSS to style the XML file as follows:

Note: The display:block style forces the next element to be on a newline.

sample.html
Now if we create a container page, where we include an iFrame we can display the xml file

Example :. The diagram following shows the result in Google's chrome.

XML and HTML
Html can be included in an xml file by adding

to the root element Using this technique allows us to for example display an image within an xml file.

So if we have an XML file (xmlImage.xml) as

And an associated style sheet (xmlImage.css)

If we put this into an iframe page for display (xmlImage.html)

Assuming the images are available, this would render in the web browser ...

Example :. The diagram following shows the result in Google's chrome.

For more information refer to (Cormia, 2011)

Examples

 * Scalable Vector Graphics (2010) : is a family of specifications of an XML-based file format for describing two-dimensional vector graphics, both static and dynamic (i.e. interactive or animated).
 * RSS Feeds use XML
 * New Zealand Herald. Click on the RSS button on http://www.nzherald.co.nz/nz/news/headlines.cfm?c_id=1 and it should link to an XML file http://rss.nzherald.co.nz/rss/xml/nzhrsscid_000000001.xml

Resources

 * XML Course Tutorials and Reference Guide (2011)