Microsoft.NET

……………………………………………….Expertise in .NET Technologies

Overview of XML

Posted by Ravi Varma Thumati on May 8, 2009

XML (Extensible Markup Language) is a W3C Recommendation for creating special-purpose markup languages. It is a simplified subset of SGML, capable of describing many different kinds of data. Its primary purpose is to facilitate the sharing of structured text and information across the Internet. Languages based on XML (for example, RDF, SMIL, MathML, and SVG) are themselves described in a formal way, allowing programs to modify and validate documents in these languages without prior knowledge of their form.

Table of contents

  • Strengths and Weaknesses
  • Syntax rules in XML
  • Document Type Definitions and XML Schemas
  • Displaying XML on the web
  • XML Extensions
  • Processing XML files
  • Versions of XML

Strengths and Weaknesses

The features of XML that make it particularly appropriate for data transfer are:

  • Compatibility with web and internet protocols
  • Simultaneously human- and machine-readable format
  • Support for Unicode representing all current and many historical character sets
  • The ability to represent the most general computer science data structures (records, lists and treess)
  • The format is self-documenting in that it describes the structure and field names as well as specific values
  • Strict syntax makes the necessary parsing algorithms fast and efficient.

XML is also heavily used for document storage and processing, both online and offline:

  • Robust, logically-verifiable format based on international standards
  • Hierarchical structure suitable for most (but not all) types of document
  • Plaintext files, unencumbered by licenses or restrictions
  • Platform-independent, so relatively immune to changes in technology
  • Has already been in use (as SGML) for long over a decade, so there is extensive experience and software available. 

The weaknesses of the format relates to matters of efficiency, since the XML

  • It is not compressed
  • Still requires further parsing to extract individual values.
  • Modeling overlapping (non-hierarchical) data structures requires extra effort.

For matters of generic, loosely bound data transfer the strengths outweigh weaknesses, and in many neutral applications where efficiency is not a particular concern XML is also coming to be adopted simply because tools to manipulate XML are now conveniently on-hand.

Syntax rules in XML

An XML document is text, usually Unicode although other encodings may be used.

Unlike, for example, HTML, XML is highly dependent upon structure, content and integrity for its efficacy. In order for a document to be considered “well-formed” [1]

  • Non-empty elements must be delimited by a start-tag and an end-tag. Empty elements may be marked with an empty-element tag.
  • All attribute values must be quoted.
  • Element names in XML are case-sensitive: for example and are a well-formed matching pair whereas and are not.
  • Also, again unlike HTML, clever choice of XML element names allows the meaning of the data to be retained as part of the markup. This makes it more easily interpreted by software programs.

As a concrete example, a simple recipe expressed in an XML representation might be:

Flour
Yeast
Warm Water
Salt          
Mix all ingredients together, and knead thoroughly.
Cover with a cloth, and leave for one hour in warm room.
Knead again, place in a tin, and then bake in the oven.

Identifying information accurately enables programs to manipulate it easily: in this example, it is now easy to convert the quantities to other measuring systems, or to print the ingredients as icons for those with low reading skills, or to refer to the individual ingredients or steps from elsewhere (another recipe, for example).

An XML document that meets certain other criteria in addition to being well-formed (such as complying with an associated DTD) is said to be “valid”.

Document Type Definitions and XML Schemas

Before the advent of generalized data description languages such as SGML and XML, software designers had to define special file formats or small languages to share data between programs. This required writing detailed specifications and special-purpose parsers and writers. For a language based on XML, however, the software designer can specify the basic syntax by writing a DTD, or a more detailed description using an XML Schema. There are readily available (and in some cases free) tools which understand these descriptions — XML parsers and writers. This may significantly reduce life-cycle development cost.

Displaying XML on the web

As a further adjunct to XML, is the stylesheet language XSL which allows users to describe visual properties and transformations of XML data without embedding those instructions into the data itself. The resulting document is then an HTML document which uses CSS for rendering.

An XML document may also be rendered directly in some browsers such as e.g. Internet Explorer 5 or Mozilla with the stylesheet language CSS. This process is still not yet stable as of January 2003. The XML document must include a reference to a style sheet: 

While browser-based XML rendering develops, the alternative is conversion into HTML or PDF or other formats on the server. Programs like Cocoon process an XML file against a stylesheet (and can perform other processing as well) and send the output back to the user’s browser without the user needing to be aware of what has been going on in the background.

XML Extensions

  • XPath It is possible to refer to individual components of an XML document using XPath. This allows stylesheets in (for example) XSL and XSLT to dynamically “cherry-pick” pieces of a document in any sequence needed in order to compose the required output.
  • XQuery is to XML what SQL is to relational databases.
  • XML namespaces enable the same document to contain XML elements and attributes taken from different vocabularies, without any naming collisions occurring.

Processing XML files

The APIs widely used in processing XML data by programming languages are SAX and DOM. SAX is used for serial processing whereas DOM is used for random-access processing.

An XSL processor may be used to render an XML file for displaying or printing. XSL itself is intended for creating PDF files. XSLT is for transforming to other formats, including HTML, other vocabularies of XML, and any other plain-text format.

The native file format of OpenOffice.org is XML. Some parts of Microsoft Office 11 will also be able to edit XML files with a user-supplied schema (but not a DTD). There are dozens of other XML editors available.

Versions of XML

The first and current version of XML is 1.0. There is a W3C Candidate Recommendation for skunk works), written by one of the original developers of XML, contains some proposals for what an XML 2.0 might look like: elimination of DTD’s from syntax, integration of Namespaces, XML Base and XML Information Set into the base standard.

Advertisements

3 Responses to “Overview of XML”

  1. Many thanks for your time to have decided to put these things together on this blog site. Michael and that i very much appreciated your input through your articles about certain things. I recognize that you have numerous demands on your program so the fact that a person like you took all the time like you did to steer people like us by this article is also highly loved.

  2. whoah this weblog is wonderful i like studying your articles. Stay up the great work! You realize, a lot of people are hunting around for this information, you can help them greatly.

  3. Congratulations on possessing definitely certainly one of one of the most refined blogs Ive arrive throughout in some time! Its simply amazing how much you’ll be capable to contemplate away from a factor principally merely because of how visually beautiful it is. Youve place collectively an important weblog site space –great graphics, films, layout. That is certainly a must-see web site!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: