XML is a markup language that can run on any platform, operating system, or environment and is designed to provide developers with a mechanism to describe their content better. Originally, it was designed for publishing projects, but later it has been developed to make exchange of data on the web much easier and efficient. It was easy to write XML but then the problem arise how to validate according to the rules. The first form of validation was possible using syntaxes very similar to XML called DTD.
DTDs are markup language rulebooks that define what markup elements can be used to describe a document. If one wants to create ones own tags then we first need to define the tag in the DTD. XML is a flexible framework to create ones own customized markup languages. All XML-based languages will share the same look and feel. They will all share a common basic syntax. After this, the developer is free to build his/her own diverse markup languages XML requires a browser which has a parser which can understand the syntaxes of XML.
E. g: Internet Explorer. This browser has the XML built in parser. There are two types of parsers, one which is only checks for the well formed document and the second one is known as validating parser. The validating parser will also check whether an XML document is well formed as well as validation of DTDs. The latest browser by Netscape i. e. Netscape supports xml. XML files are documented in notepad and are saved with . XML extension. When there is complex information to be evaluated and executed XML Schemas are used.
XML Schemas go several steps further than DTDs by allowing you to associate rich data types with elements, and eventually with attributes as well. In a DTD, element content is limited to strings and a few other primitive data types. XML Schema supports a wide range of rich data types, such as integers, floating point, numbers, dates, and times. XML Schema also includes support for other features, such as an open content model and namespace integration. The following is a list of the major benefits offered by XML Schema compared to DTDs: 1. XML Schemas are based on XML, not some specialized syntax.
2. XML can be parsed and manipulated just like another XML documents. 3. XML Schemas support a variety of data types. (int, float, Boolean, date etc. ) 4. XML Schema presents an open-ended data model, which allows you to extend vocabularies and establish inheritance relationships between elements without invalidating documents. 5. XML Schemas support namespace integration, which allows you to associate individual nodes of a document with type declarations in a schema. 6. XML Schemas support attribute groups, which allow you to logically combine attributes.
In short we can say XML Schema is a much-advanced form of DTDs. Now, when executed alone, the XML documents will show an output as it was written. XML documents are not formatted by default as HTML documents are. CSS is one of those stylesheets. Thus Cascading Style Sheets (CSS) are used for formatting XML documents. (CSS) is a relatively simple tool that allows the developer to assign styles to HTML elements. CSS duplicates formatting built into HTML. It provides web developers with access to a large variety of formatting properties such as margins, line-height, word spacing, and many more.
One XML document can be formatted in many different ways just by changing the style sheet. Different style sheets can be designed for different purposes. CSS actually works better with XML than with HTML because HTML is burdened with backward compatibility between CSS and HTML tags. CSS is easy to learn and style sheets can be included directly in xml documents or can be saved as standalone text files. The only drawback is that style sheet is browser related and hence the developer needs to take care while developing it.
A CSS style sheet is a list of rules. Each rule gives the names of the elements it applies to and the styles it wants to apply to those elements. Several style sheets can exist for one document allowing one document to be rendered by a wide range of formatting devices from web browsers to printers. Multiple style sheets can be written to provide different output on the same formatting device. In order to display XML documents in a presentable form, it is necessary to have a mechanism to describe how the document should be displayed.
One of these mechanisms that we have seen is Cascading Style Sheets (CSS). Apart from this, the W3C has proposed a style-sheet language for XML, called Extensible Stylesheet Language (XSL). XSL is the preferred style sheet language of XML, and XSL is far more sophisticated than CSS. XSL was developed from a proposal forwarded by a group of editors representing Microsoft, Inso, ArborText, and the University of Edinburgh, along with James Clark. XSL makes XML more powerful which enables conditional formatting and application of programming to an extent.
Document Object Model (DOM) is also an important aspect of XML. DOM is used to create a tree structure of a well-formed xml document. DOM facilitates adding of object to tree structure. DOM is the means by which user can access and manipulate XML document. With DOM, XML promises an application-independent programming language. XML is one of the popular languages used on web for data interchange. The DOM output can be viewed in a web browser. The web browser has its own object hierarchy in which the Document object is at top, that is why it is known as Document object model.
A Document object model is a tree like structure that holds different object that help in presenting and holding the data. A document object model is based on the concept of object oriented paradigm. In Object oriented paradigm, a common DOM API (Application Programming Interface) is used to allow programmers to write one set of code that can interpret documents running on any application or platform. DOM is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents.
Lets take an example of the company, which is having centralized employee records at X office maintained in XML format. This company has four more offices at the metropolitan. A new employee can join any of the branches. The responsibility of updating employee record is of the operator. Operator has to update, if any new designation is added to the organization. For updating, first requirement is interface, which is provided by DOM to access the centralized employee records from any of the offices i. e. using DOM the centralized employee records (stored in XML format) are updated.
The centralized employee records can be further used for processing to execute certain queries like how many new employees joined the previous month? After processing the database i. e. the centralized employee records for the query the database can be presented back to XML format. DOM is an interface, which can be embedded into HTML and XML documents using script. It describes the way a document can be accessed and manipulated. Using DOM, a programmer can create a document, navigate its structure and add, modify or delete its elements. To access the information of XML document we need to use the interfaces of DOM.