XML |
The Extensible Markup Language (XML) is a World Wide Web Consortium-recommended general-purpose markup language for creating special-purpose markup languages. It is a simplified subset of Standard Generalized Markup Language, capable of describing many different kinds of Data. Its primary purpose is to facilitate the sharing of data across different systems, particularly systems connected via the Internet. Languages based on XML (for example, Resource Description Framework, RSS (file format), MathML, XHTML, Scalable Vector Graphics, and cXML) are defined in a formal way, allowing programs to modify and validate documents in these languages without prior knowledge of their form.
=History=
By the mid-1990s some practitioners of SGML had gained experience with the then-new World Wide Web, and believed that SGML offered solutions to some of the problems the Web was likely to face as it grew. Jon Bosak argued that the W3C should sponsor an SGML on the Web activity. After some resistance he was authorized to launch that activity in mid-1996, albeit with little involvement by or support from the W3C leadership. Bosak was well-connected in the small community of people who had experience both in SGML and the Web. He received support in his efforts from Microsoft.
XML was designed by an eleven-member Working Group supported by an (approximately) 150-member Interest Group. Technical debate took place on the Interest Group mailing list and issues were resolved by consensus or, when that failed, majority vote of the Working Group. James Clark (XML expert) served as Technical Lead of the Working Group, notably contributing the empty-element syntax and the name XML . Other names that had been put forward for consideration included MAGMA (Minimal Architecture for Generalized Markup Applications), SLIM (Structured Language for Internet Markup) and MGML (Minimal Generalized Markup Language). The co-editors of the specification were originally Tim Bray and Michael Sperberg-McQueen. Halfway through the project Bray accepted a consulting engagement with Netscape Communications Corporation, provoking vociferous protests from Microsoft. Bray was temporarily asked to resign the editorship. This led to intense dispute in the Working Group, eventually solved by the appointment of Microsoft s Jean Paoli as a third co-editor.
The XML Working Group never met face-to-face; the design was accomplished using a combination of email and weekly teleconferences. The major design decisions were reached in twenty weeks of intense work between July and November of 1996. Further design work continued through 1997 and XML 1.0 became a W3C Recommendation on February 10, 1998.
XML may be viewed as a variant of LISP S-expressions which form tree structures where each node may have its own property list.
XML is suitable for management, display, and organization of data. XML is a technology concerned with the description and structuring of data.
Binary files are proprietary . One might not be able to open binary files created by one application in another application, or even in the same application running on another platform. Text files are also streams of bits. However, in a text file these bits are grouped together in standardized ways, so that they always form numbers. These numbers are then further mapped to characters.
XML format combines the universality of text files with the efficiency and rich information storage capabilities of binary files. XML describes a syntax that you use to create your own languages. XML is about making it easier to write software that accesses the information, by giving structure to data. With XML there is a standardized way to get the information no matter how we structure the data. So with new structure of data comes a new methodology to pull the information and XML can ease this process by standardization of the structure.
= Strengths and weaknesses =
Some features of XML that make it well-suited for data transfer are:
XML is also heavily used as a format for document storage and processing, both online and offline, and offers several benefits:
For certain applications, XML also has the following weaknesses:
=Quick syntax tour=
Here is an example of a simple recipe expressed using XML:
Basic bread 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.
The first line is the XML declaration: it is an optional line stating what version of XML is in use (normally version 1.0), and may also contain information about character encoding and external dependencies.
The remainder of this document consists of nested element s, some of which have attribute s and content . An element typically consists of two tags, a start tag and an end tag , possibly surrounding text and other elements. The start tag consists of a name surrounded by angle brackets, like <step> ; the end tag consists of the same name surrounded by angle brackets, but with a forward slash preceding the name, like </step> . The element s content is everything that appears between the start tag and the end tag, including text and other (child) elements. The following is a complete XML element, with start tag, text content, and end tag:
Knead again, place in a tin, and then bake in the oven.
In addition to content, an element can contain attributes — name-value pairs included in the start tag after the element name. Attribute values must always be quoted, using single or double quotes, and each attribute name should appear only once in any element.
Flour
In this example, the ingredient element has two attributes: amount , having value 3 , and units, having value cups . In both cases, at the markup level, the names and values of the attributes, just like the names and content of the elements, are just textual data — the 3 and cups are not a quantity and unit of measure, respectively, but rather are just character sequences that the document author may be using to represent those things.
In addition to text, elements may contain other elements:
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.
In this case, the Instructions element contains three step elements. XML requires that elements be properly nested — elements may never overlap. For example, this is not well-formed XML, because the em and strong elements overlap:
<!-- WRONG! NOT WELL-FORMED XML! --> <p>Normal <em>emphasized <strong>strong emphasized</em> strong</strong></p>
Every XML document must have exactly one top-level root element (alternatively called a document element ), so the following would also be a malformed XML document:
<xml version= 1.0 encoding= UTF-8 > <!-- WRONG! NOT WELL-FORMED XML! --> <thing>Thing one</thing> <thing>Thing two</thing>
XML provides special syntax for representing an element with empty content. Instead of writing a start tag followed immediately by an end tag, a document may contain the empty element tag where a slash follows the element name. The following two examples are functionally equivalent:
<foo></foo>
<foo/>
XML provides two methods for escaping (or simply representing) special characters: entity references and numeric character references . An entity in XML is a named body of data, usually representing text, such as an unusual character. An entity reference is a placeholder for that entity, and consists of the entity s name preceded by an ampersand ( & ) and followed by a semicolon ( ; ). XML has several predeclared entities, such as lt (referenced as < ) for the left angle bracket (<) and amp (referenced as & ) for the ampersand (&) itself, and it is possible to declare additional ones if desired. Aside from representing individual characters, reproducing chunks of boilerplate text is another common use for entities. Here is an example using a predeclared XML entity to escape the ampersand in the name AT&T :
<company-name>AT&T</company-name>
The full list of predeclared entities are
If more entities need to be declared, this is done in the document s XML#DTD , which is not demonstrated in this example, for brevity.
Numeric character references look like entities, but instead of a name, they contain the number sign character followed by a number between the ampersand and the semicolon. The number (in decimal or hexadecimal) represents a Unicode code point, and is typically used to represent characters that are not easily encodable, such as an Arabic character in a document produced on a European computer. The ampersand in the AT&T example could also be escaped like this (decimal 38 is the Unicode value for & ):
<company-name>AT&T</company-name>
There are many more rules necessary to be sure of writing well-formed XML documents, such as the exact characters allowed in an XML name, but this quick tour provides the basics necessary to read and understand many XML documents.
=Correctness in an XML document=
For an XML document to be correct, it must be:
==Well-formed documents==
An XML document is text, which is a sequence of characters. The specification requires support for Unicode encodings UTF-8 and UTF-16 (UTF-32 is not mandatory). The use of other non-Unicode based encodings, such as ISO-8859, is admitted and is indeed widely used and supported.
A well-formed document must conform to the following rules, among others:
Element names are case-sensitive. For example, the following is a well-formed matching pair :<Step> ... </Step> whereas this is not :<Step> ... </step>
The careful choice of names for XML elements will convey the meaning of the Data in the markup (computing). This increases human readability while retaining the rigor needed for software parsing.
Choosing meaningful names implies the semantics of elements and attributes to a human reader without reference to external documentation. However, this can lead to verbosity, which complicates authoring and increases file size.
==Valid documents==
An XML document that complies with a particular schema, in addition to being well-formed, is said to be valid.
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic constraints imposed by XML itself. A number of standard and proprietary XML schema languages have emerged for the purpose of formally expressing such schemas, and some of these languages are XML-based, themselves.
Before the advent of generalised 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.
XML s regular structure and strict parsing rules allow software designers to leave parsing to standard tools, and since XML provides a general, data model-oriented framework for the development of application-specific languages, software designers need only concentrate on the development of rules for their data, at relatively high levels of abstraction.
Well-tested tools exist to validate an XML document against a schema: the tool automatically verifies whether the document conforms to constraints expressed in the schema. Some of these validation tools are included in XML parsers, and some are packaged separately.
Other usages of schemas exist: XML editors, for instance, can use schemas to support the editing process.
===DTD===
The oldest schema format for XML is the Document Type Definition (DTD), inherited from SGML. While DTD support is ubiquitous due to its inclusion in the XML 1.0 standard, it is seen as limited for the following reasons:
===XML Schema===
A newer XML schema language, described by the W3C as the successor of DTDs, is XML Schema, or more informally referred to in terms of the acronym and initialism for XML Schema instances, XSD (XML Schema Definition). XSDs are far more powerful than DTDs in describing XML languages. They use a rich datatyping system, allow for more detailed constraints on an XML document s logical structure, and are required to be processed in a more robust validation framework. Additionally, XSDs use an XML based format, which makes it possible to use ordinary XML tools to help process them, although WXS (W3C XML Schema) implementations require much more than just the ability to read XML.
Criticisms of WXS include the following: *The specification is very large, which makes it difficult to understand and implement. *The XML-based syntax leads to verbosity in schema description, which makes XSDs harder to read and write.
===RELAX NG===
Another popular schema language for XML is s [http://www.thaiopensource.com/relaxng/trang.html Trang conversion tool], the advantage of using standard XML tools is not lost. Compared to XML Schema, RELAX NG has a simpler definition and validation framework, making it easier to use and implement. It also has the ability to use any datatype framework on a plug-in basis; for example, a RELAX NG schema author can require values in an XML document to conform to definitions in XML Schema Datatypes.
===Other schema languages===
Some schema languages not only describe the structure of a particular XML format but also offer limited facilities to influence processing of individual XML files that conform to this format. DTDs and XSDs both have this ability; they can for instance provide attribute defaults. RELAX NG intentionally does not provide these facilities.
== International and worldwide use ==
XML fully supports unicode character encodings in element names, attributes and data. Therefore the following is a perfectly well-formed XML document, even though it includes both Chinese and Russian characters:
<xml version= 1.0 encoding= UTF-8 > <></>
= Displaying XML on the web =
Extensible Stylesheet Language (XSL) is a supporting technology that describes how to format or transform the data in an XML document. The document is changed to a format suitable for browser display. The process is similar to applying a Cascading Style Sheets to an HTML document for rendering.
Without using CSS or XSL, a generic XML document is rendered as raw XML text by most web browsers. Browsers like Internet Explorer, Mozilla and Mozilla Firefox display it with handles that allow parts of the structure to be expanded or collapsed with mouse-clicks.
In order to style the rendering in a browser with CSS, the XML document must include a special reference to the stylesheet:
:<xml-stylesheet type= text/css href= myStyleSheet.css >
See the CSS article Cascading Style Sheets#Example_of_applying_CSS_to_.27plain.27_XML.
This is different from specifying a stylesheet in HTML, which uses the <link> element.
To specify a client-side XSL Transformations (XSLT), the following processing instruction is required in the XML:
:<xml-stylesheet type= text/xsl href= transform.xsl >
Client-side XSLT is not yet supported in Opera (web browser).
The alternative is conversion of XML into HTML, PDF and other formats on the server . Many Extensible Stylesheet Language exist, and the end-user then need not be aware of what has been going on behind the scenes .
See the XSLT article XSL_Transformations#Example.
= XML extensions =
= Processing XML files =
Simple API for XML and DOM (XML API) are Application programming interfaces widely used to process XML data. SAX is used for serial processing whereas DOM is used for random-access processing. Another form of XML Processing API is data binding, where XML data is made available as a strongly typed programming language data structure, in contrast to the DOM. Example data binding systems are the Java Architecture for XML Binding (JAXB) [http://java.sun.com/xml/jaxb/] and the Strathclyde Novel Architecture for Querying XML (SNAQue) [http://www.cis.strath.ac.uk/research/snaque/].
A filter in the Extensible Stylesheet Language (XSL) family can transform an XML file for displaying or printing.
The native file format of OpenOffice.org and AbiWord 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), and on June 2, 2005 Microsoft announced that, by late 2006 all the files created by users of its Office suite of software will be formatted with web-centered XML specifications. There are dozens of other XML editors available.
= Versions of XML =
There are two current versions of XML. The first, XML 1.0 , was initially defined in 1998. It has undergone minor revisions since then, without being given a new version number, and is currently in its third edition, as published on February 4, 2004. It is widely implemented and still recommended for general use. The second, XML 1.1 , was initially published on the same day as XML 1.0 Third Edition. It contains features — some contentious — that are intended to make XML easier to use for certain classes of users (mainframe programmers, mainly). XML 1.1 is not very widely implemented and is recommended for use only by those who need its unique features.
XML 1.0 and XML 1.1 differ in the requirements of characters used for element names, attribute names etc.: XML 1.0 only allows characters which are defined in Unicode 2.0, which includes most world scripts, but excludes scripts which only entered in a later Unicode version, such as Mongolian language, Cambodian language, Amharic, Burmese language, etc.. XML 1.1 only disallows certain control characters, which means that any other character can be used, even if it is not defined in the current version of Unicode.
It should be noted here that the restriction present in XML 1.0 only applies to element/attribute names: both XML 1.0 and XML 1.1 allow for the use of full Unicode in the content itself. Thus XML 1.1 is only needed if in addition to using a script added after Unicode 2.0 you also wish to write element and attribute names in that script.
Other minor changes between XML 1.0 and XML 1.1 are that control characters are now allowed to be included but only when escaped, and two special Unicode line break characters are included, which must be treated as whitespace.
XML 1.0 documents are well-formed XML 1.1 documents with one exception: XML documents that contain unescaped C0 and C1 control codes#C1 (ISO-8859 and unicode) control characters are now malformed: this is because XML 1.1 requires the C1 control characters to be escaped with numeric character references.
There are also discussions on an XML 2.0, although it remains to be seen if such will ever come about. XML-SW (SW for ( infoset ) into the base standard.
The World Wide Web Consortium also has a XML Binary Characterization Working Group doing preliminary research into use cases and properties for a binary encoding of the XML infoset. The working group is not chartered to produce any official standards. Since XML is by definition text-based, ITU-T and ISO are using the name [http://asn1.elibel.tm.fr/xml/finf.htm Fast Infoset] for their own binary infoset to avoid confusion (see ITU-T Rec. X.891 | ISO/IEC 24824-1).
=See also=
*XML processing *Cascading Style Sheets, Extensible Stylesheet Language *S-expression, XML query language *Abstract syntax tree (AST) *XRI, XDI *Extensible Metadata Platform (XMP), used in graphics applications *Scalable Vector Graphics *ASN.1 *WBXML *Serialization *List of general purpose markup languages *Comparison of general purpose markup languages *Comparison of layout engines (XML) *Single source publishing *Extensible Binary Meta Language=References=
=External links=
==Specifications==
*[http://www.w3.org/XML/ World Wide Web Consortium XML homepage] *[http://www.w3.org/TR/REC-xml The XML 1.0 specification] *[http://www.w3.org/TR/xml11 The XML 1.1 specification]
==Basic Readings==
*[http://xml.silmaril.ie/ The XML FAQ] *[http://www.xml.com/axml/testaxml.htm Annotated XML Specification] *[http://www.mousewhisperer.co.uk/xml_page.html Absolute Beginners XML Tutorial] *[http://www.w3schools.com/ W3 Schools has an excellent tutorial]
==Web-Zines==
*[http://www.xml.com/ XML.com]
==XML Editors==
*[http://autoxml.atspace.com AutoXML] Text-based editor with limited XML-awareness. Freeware. *[http://www.editix.com EditiX] Commercial. *[http://www.philo.de/xmledit OpenXml Editor] Text-based editor. Open source (Delphi). *[http://www.freexmleditor.com Exchanger XML Lite] Free XML Editor from Cladonia. *[http://www.oxygenxml.com oXygen] Commercial. *[http://www.xmlspy.com XmlSpy] Commercial. *[http://ephox.com/product/editliveforxml Ephox EditLive! for XML] Commercial.
==XML Certification==
*[http://www.whizlabs.com/products/xmlwhiz/xmlwhiz.html XML Certification Exam Prepration] *[http://www-03.ibm.com/certify/certs/adcdxmlrt.shtml IBM XML Certification] *[http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgiubb=forum&f=52 JavaRanch XML Certification Discussion Forum] *[http://www.certlobby.com/ibm/xml-certification.html XML Certification Preparation Center]
==XML Parsers==
|
|