|
Summary
Briefly describes XML history
History of XML
How XML evolved
XML is the biggest thing to hit the Web since its evolution. It is also biggest thing for information management. XML doesn’t do anything on its own, all it provides is a way of structuring information and sending it from one piece of software to another. XML started coming into picture around 1996-1997 under the guidance of editors Jon Bosak, Tim Bray, C. M. Sperberg-McQueen along with other members of W3C. Part of its success comes from because it’s easily readable, writable and any XML document can be opened in simple text editor, but the fact is it’s primarily intended for communication between different software systems. With the fast evolution of web XML satisfies many compelling requirements:
Separating data from presentation: The need to separate information from the details, the way it is to be presented on a particular device. This need is becoming even more urgent as range of intenet capable devices grows. Delivery of Information is going beyond PC based browsers to TV sets and WAP phones.
Transmitting data between applications: Different applications within an organization or beyond its boundaries are able to exchange data without any limitations of not compatible protocols and without investing in software integration projects.
Ease of use: In XML, documents are easy and quick to create. Instead of storing and retrieving information all the time in proprietary databases (Access, SQL Server and Oracle), it’s another medium for information storage and nice part and it’s based on open public standard. Above all, language of the documents is human legible.
But let’s see what was missing in already available languages mainly SGML and HTML, which could not accomplish above tasks. After all, any computer in this world runs with HTTP protocols, which should be able to accept any documents from any other different machine or other desired tasks for web or non-web applications. Then why XML?
One main reason - XML grew out of SGML complexity and inadequacies of HTML.
Let’s take HTML first.
HTML has its limitations with fixed set of tags. I cannot have a tag “ABRACADABRA†in HTML but in XML I can surely define it and use it for whatever purpose I want. Beauty of XML is that it has no fixed tags and semantics. It’s a Meta data for markup language. In simplicity-you define your XML document with your own set of tags (whichever way you want, but well balanced and well formed, explained later) and let the other application or Style sheets use it and process it the way application demands. Isn’t it great?
But Remember XML did not replace HTML. HTML is still the primary language and medium to tell the browsers how to display the information on the web. I will define terms “well balanced and well formed†after SGML.
SGML.
SGML is the mother of all markup languages. Both HTML and XML are derived from SGML. Like XML, SGML also allows to describe specific type of documents that you work with. But biggest disadvantage of SGML is “ease of implementationâ€. SGML is too complicated. It was difficult to process and display the SGML information in Web Browsers. XML is simplified version of SGML.
XML document
Let’s take an example how typical XML document will look like. Let’s say there is need to send information to the browser about certain books, there author and publishers. Way by XML:
<Book>
<Name>My First Kindergarten Book</Name>
<Author>John Cook</Author>
<Publisher>PBS</Publisher>
</Book>
<Book>
<Name>My First Disney Book</Name>
<Author>Harry Miller</Author>
<Publisher>Disney</Publisher>
</Book>
<Book>
<Name>ABCD of XML</Name>
<Author>Henry Walsh</Author>
<Publisher>WROX</Publisher>
</Book>
The above document is well balanced, since for each opening tag (Book, Name, Author and Publisher are called tags or elements) there is closing one (</Book>, </Name>, </Author> and </Publisher>). But it’s not well formed, as there is no single enclosing element for all these elements. The same above information is well formed when it is represented as:
<Books>
<Book>
<Name>My First Kindergarten Book</Name>
<Author>John Cook</Author>
<Publisher>PBS</Publisher>
</Book>
<Book>
<Name>My First Disney Book</Name>
<Author>Harry Miller</Author>
<Publisher>Disney</Publisher>
</Book>
<Book>
<Name>ABCD of XML</Name>
<Author>Henry Walsh</Author>
<Publisher>WROX</Publisher>
</Book>
</Books>
Now the complete information is represented under one single element “Booksâ€. Books element is the entry point for this document, which can be termed as root node. The information within each tag (My first kindergarten book, John cook, PBS and others) is called text or data.
Click here to view the above information in browser.
What you just saw in the browser is raw XML, with no format, no presentation styles. What you would like to see is Click here.
This information about books can be used for viewing or can be feed into other software application. The main point is whether XML data is ultimately used by people or by software application, it will very rarely be used directly in the form it arrives: it first has to be transformed into something else. XSLT is one common way of doing this.
XSLT, which stands for extensible style sheet language is primarily designed for transforming one XML document to other XML or HTML document as shown in the above example.
The Place of XSLT in the XML family.
XSLT is published by the World Wide Web consortium (W3C) and fits into XML family of standards, most of which are also developed by W3C.
How does XSLT transform XML?
You are probably wondering how XSLT goes about processing an XML document in order to convert it into required output. There are usually two aspects to this process:
- The first stage is structural transformation, in which the data is converted from the structure of the incoming XML document to a structure that reflects the desired output.
- The second stage is the formatting, in which new structure is output in the required format such as HTML or PDF.
Note: XSLT engines do not manipulate the documents; they manipulate structures.
Click here to view XSLT for the above book-publisher example.
Let me explain what does each command line in this XSLT mean.
The xsl:stylesheet element indicates that this document is a style sheet. It’s also called the declarative section. Declaration http://www.w3.org/1999/XSL/Transform is called namespace. The attribute xmlns is an XML keyword and is understood by namespace-aware XML parsers.
Xsl:apply-templates instruction defines a set of nodes to be processed and causes the system to process them by selecting an appropriate template rule for each one. Its an instruction which is always used within a template body.
Effect of apply-template: Apply-template element select a set of nodes in the input tree and process each of them individually by finding a matching template rule for that node. The set of nodes is determined by select attribute; the order in which they are processed is determined by the <xsl:sort> elements (if present) and the parameters passed to the template rules are determined by the <xslwith-param> elements (if present).
You can explore XML and XSLT more through these XML Sites:
http://www.TOPXML.COM
http://www.XML.COM
http://www.textuality.com/xml/faq.html
http://www.XML101.COM
|