![]() |
|
|
| |
|
||||
Strengths and weaknessesThe features of XML that make it particularly appropriate for data transfer are:
XML is also heavily used as the format for document storage and processing, both online and offline, and offers several benefits:
For certain applications, the format also has the following weaknesses:
Correctness in an XML documentFor an XML document to be correct, it must be:
Well-formed documentsAn XML document is text, usually a particular encoding of Unicode such as UTF-8 or UTF-16, although other encodings may be used. 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
whereas this is not
The careful choice of names for XML elements will convey the meaning of the data in the markup. This increases human readability while retaining the rigor needed for software parsing. For example, a simple recipe might be expressed in XML as: <?xml version="1.0" encoding="UTF-8"?>
<Recipe name="bread" prep_time="5 mins" cook_time="3 hours">
<title>Basic bread</title>
<ingredient amount="3" unit="cups">Flour</ingredient>
<ingredient amount="0.25" unit="ounce">Yeast</ingredient>
<ingredient amount="1.5" unit="cups">Warm Water</ingredient>
<ingredient amount="1" unit="teaspoon">Salt</ingredient>
<Instructions>
<step>Mix all ingredients together, and knead thoroughly.</step>
<step>Cover with a cloth, and leave for one hour in warm room.</step>
<step>Knead again, place in a tin, and then bake in the oven.</step>
</Instructions>
</Recipe>
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 documentsAn 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. DTDThe 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 schemaA newer XML schema language, described by the W3C as the successor of DTDs, is simply called XML Schema, also referred to as XML Schema Definition (XSD). XSD schemas are far more powerful than DTDs in describing XML languages. Additionally XSD uses an XML based format, which makes it possible to use the XML toolset to help process XML schema. It also becomes possible to write a schema for the schema language itself. Criticisms of XSD are:
RELAX NGAnother XML popular schema language is RELAX NG. Initially standardized by OASIS and now also a ISO international standard (as part of DSDL), RELAX NG comes in two formats, an XML based syntax and a non-XML compact syntax. The compact syntax aims to increase readability and writability, but since there is a well-defined way to translate compact syntax to the XML syntax and back again the advantage of using standard XML tools is not lost. RELAX NG has a more compact definition which makes it easier to implement than XSD. Other schema languagesSome 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. Displaying XML on the webExtensible 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 CSS to an HTML document for rendering. A line at the top of an XML document:
declares that 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 March 2004 in those browsers; in other browsers, such as Opera, this works very well. In order to allow CSS styling, the XML document must include a special reference to a style sheet:
This is different from the standard HTML way to apply a stylesheet, which uses the 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
Processing XML filesSAX and DOM are APIs 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 constrast to the DOM. Example data binding systems are the Java Architecture for XML Binding (JAXB) [1] (http://java.sun.com/xml/jaxb/) and the Strathclyde Novel Architecture for Querying XML (SNAQue) [2] (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). There are dozens of other XML editors available. Versions of XMLThere 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 primarily 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 valid Unicode 2.0, which includes most world scripts, but excludes scripts which only entered in a later Unicode version, such as Mongolian, Cambodian, Amharic, Burmese, etc.. XML 1.1 only disallows certain control characters, which means that any other character can be used, even if the Unicode standard grows exponentially. 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 'form-feed' 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 C1 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 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 DTDs from syntax, integration of namespaces, XML Base and XML Information Set (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, Sun Microsystems has proposed the name fast infoset for its own binary infoset to avoid confusion, and is working to standardize that through ISO. See also
External links
|
||
|
|
|
|
|
|
Copyright 2008 WordIQ.com - Privacy Policy
::
Terms of Use
:: Contact Us
:: About Us This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "XML". |