class
attribute in an [[HTML element]], but with fewer restrictions.
[10990240] |Some W3C XML namespaces/schema that can be mixed with XHTML include [[MathML]] for semantic math markup, [[Scalable Vector Graphics]] for markup of vector graphics, and [[RDFa]] for embedding [[Resource Description Framework|RDF]] data.
[10990250] |=== Relationship to HTML ===
[10990260] |HTML is the [[antecedent]] technology to XHTML.
[10990270] |The changes from HTML to first-generation XHTML 1.0 are minor and are mainly to achieve conformance with XML.
[10990280] |The most important change is the requirement that the document must be [[well-formed element|well-formed]] and that all [[HTML element|elements]] must be explicitly closed as required in XML.
[10990290] |In XML, all element and attribute names are [[case-sensitive]], so the XHTML approach has been to define all tag names to be lowercase.
[10990300] |This contrasts with some earlier established traditions which began around the time of HTML 2.0, when many used uppercase tags.
[10990310] |In XHTML, all attribute values must be enclosed by quotes; either single ('
) or double ("
) quotes may be used.
[10990320] |In contrast, this was sometimes optional in SGML-based HTML, where numeric or boolean attributes can omit quotes.
[10990330] |All elements must also be explicitly closed, including empty (aka [[singleton]]) elements such as img
and br
.
[10990340] |This can be done by adding a closing slash to the start tag, ''e.g.'', <img />
and <br />
.
[10990350] |Attribute minimization (e.g., <option selected>
) is also prohibited, as the attribute selected
contains no explicit value; instead this would be written as <option selected="selected">
.
[10990360] |HTML elements which are optional in the content model will not appear in the [[Document Object Model|DOM]] tree unless they are explicitly specified.
[10990370] |For example, an XHTML page ''must'' have a <body>
element, and a table will not have a <tbody>
element unless the author specifies one.
[10990380] |The XHTML 1.0 recommendation devotes a section to differences between HTML and XHTML..
[10990390] |The WHATWG wiki similarly considers differences that arise with the use of (X)HTML5..
[10990400] |Because XHTML and HTML are closely related technologies, sometimes they are written about and documented in parallel.
[10990410] |In such circumstances, some authors conflate the two names by using a parenthetical notation, such as (X)HTML.
[10990420] |This indicates that the documentation and principles can be considered to apply generally to both standards.
[10990430] |=== Adoption ===
[10990440] |The similarities between HTML 4.01 and XHTML 1.0 led many web sites and content management systems to adopt the initial W3C XHTML 1.0 Recommendation.
[10990450] |To aid authors in the transition, the W3C provided guidance on how to publish XHTML 1.0 documents in an HTML-compatible manner, and serve them to browsers that were not designed for XHTML.
[10990460] |Such "HTML-compatible" content is sent using the HTML media type (text/html
) rather than the official Internet media type for XHTML (application/xhtml+xml
).
[10990470] |When measuring the adoption of XHTML to that of regular HTML, therefore, it is important to distinguish whether it is media type usage or actual document contents that is being compared.
[10990480] |Most web browsers have mature support for all of the possible XHTML media types.
[10990490] |The notable exception is [[Internet Explorer]] by [[Microsoft]]; rather than rendering application/xhtml+xml
content, a dialog box invites the user to save the content to disk instead.
[10990500] |Both Internet Explorer 7 (released in 2006) and the initial beta version of Internet Explorer 8 (released in March 2008) exhibit this behaviour, and it is unclear whether this will be resolved in a future release.
[10990510] |Whilst this remains the case, most web developers avoid using XHTML that isn’t HTML-compatible, so advantages of XML such as namespaces, faster parsing and smaller-footprint browsers do not benefit the user.
[10990520] |Microsoft developer Chris Wilson explained in 2005 that IE7’s priorities were improved security and [[Cascading Style Sheet|CSS]] support, and that proper XHTML support would be difficult to graft onto IE’s compatibility-oriented HTML parser.
[10990530] |Recently, notable developers have begun to question why Web authors ever made the leap into authoring in XHTML.
[10990540] |In October 2006, HTML inventor and W3C chair [[Tim Berners-Lee]], explaining the motivation for the resumption of HTML (not XHTML) development, posted in his blog: "The attempt to get the world to switch to XML, including quotes around attribute values and slashes in empty tags and namespaces all at once didn't work.
[10990550] |The large HTML-generating public did not move, largely because the browsers didn't complain."
[10990560] |== Versions of XHTML ==
[10990570] |=== XHTML 1.0 ===
[10990580] |December 1998 saw the publication of a W3C Working Draft entitled ''Reformulating HTML in XML''.
[10990590] |This introduced Voyager, the codename for a new markup language based on HTML 4 but adhering to the stricter syntax rules of XML.
[10990600] |By February 1999 the specification had changed name to ''XHTML™ 1.0: The Extensible HyperText Markup Language'', and in January 2000 it was officially adopted as a W3C Recommendation.
[10990610] |There are three formal [[Document Type Definition|DTDs]] for XHTML 1.0, corresponding to the three different versions of HTML 4.01:
[10990620] |* '''XHTML 1.0 Strict''' is the equivalent to strict HTML 4.01, and includes elements and attributes that have not been marked deprecated in the HTML 4.01 specification.
[10990630] |* '''XHTML 1.0 Transitional''' is the equivalent of HTML 4.01 Transitional, and includes the presentational elements (such as center
, font
and strike
) excluded from the strict version.
[10990640] |* '''XHTML 1.0 Frameset''' is the equivalent of HTML 4.01 Frameset, and allows for the definition of [[frameset|frameset documents]]—a common Web feature in the late 1990s.
[10990650] |The second edition of XHTML 1.0 became a W3C Recommendation in August 2002.
[10990660] |=== Modularization of XHTML ===
[10990670] |The initial draft of ''Modularization of XHTML'' became available in April 1999, and reached Recommendation status in April 2001.
[10990680] |[[XHTML Modularization|Modularization]] provides an abstract collection of components through which XHTML can be subsetted and extended.
[10990690] |The feature is intended to help XHTML extend it’s reach onto emerging platforms, such as mobile devices and Web-enabled televisions.
[10990700] |The first XHTML Family Markup Languages to be developed with this technique were XHTML 1.1 and XHTML Basic 1.0.
[10990710] |Another example is XHTML-Print (W3C Recommendation, September 2006), a language designed for printing from mobile devices to low-cost printers.
[10990720] |In 2008 ''Modularization of XHTML'' is expected to be superseded by ''XHTML Modularization 1.1'', which adds an [[XML Schema (W3C)|XML Schema]] implementation.
[10990730] |=== XHTML 1.1—Module-based XHTML ===
[10990740] |XHTML 1.1 evolved out of the work surrounding the initial ''Modularization of XHTML'' specification.
[10990750] |The W3C released a first draft in September 1999; Recommendation status was reached in May 2001.
[10990760] |The modules combined within XHTML 1.1 effectively recreate XHTML 1.0 Strict, with the addition of [[ruby character|ruby annotation]] elements (ruby
, rbc
, rtc
, rb
, rt
and rp
) to better support East-Asian languages.
[10990770] |Other changes include removal of the lang
attribute (in favour of xml:lang
), and removal of the name
attribute from the a
and map
elements.
[10990780] |Although XHTML 1.1 is largely compatible with XHTML 1.0 and HTML 4, in August 2002 the W3C issued a formal Note advising that it should not be transmitted with the HTML media type.
[10990790] |With limited browser support for the alternate application/xhtml+xml
media type, XHTML 1.1 has so far proven unable to gain widespread use.
[10990800] |XHTML 1.1 Second Edition is expected in the third quarter of 2008.
[10990810] |=== XHTML Basic and XHTML-MP ===
[10990820] |To support constrained devices, ''[[XHTML Basic]]'' was created by the W3C; it reached Recommendation status in December 2000.
[10990830] |XHTML Basic 1.0 is the most restrictive version of XHTML, providing a minimal set of features that even the most limited devices can be expected to support.
[10990840] |The [[Open Mobile Alliance]] and it’s predecessor the WAP Forum released three specifications between 2001 and 2006 that extended XHTML Basic 1.0.
[10990850] |Known as [[XHTML Mobile Profile]] or XHTML-MP, they were strongly focussed on uniting the differing markup languages used on [[mobile phone|mobile handsets]] at the time.
[10990860] |All provide richer form controls than XHTML Basic 1.0, along with varying levels of scripting support.
[10990870] |''XHTML Basic 1.1'' became a W3C Proposed Recommendation in June 2008, superseding XHTML-MP 1.2.
[10990880] |XHTML Basic 1.1 is almost but not quite a subset of regular XHTML 1.1.
[10990890] |The most notable addition over XHTML 1.1 is the inputmode
attribute—also found in XHTML-MP 1.2—which provides hints to help browsers improve form entry.
[10990900] |=== XHTML 1.2 ===
[10990910] |The XHTML 2 Working Group is considering the creation a new language based on XHTML 1.1.
[10990920] |If XHTML 1.2 is created, it will include [[WAI-ARIA]] and role
attributes to better support accessible web applications, and improved [[Semantic Web]] support through [[RDFa]].
[10990930] |The inputmode
attribute from XHTML Basic 1.1, along with the target
attribute (for specifying [[Framing (World Wide Web)|frame]] targets) may also be present.
[10990940] |=== XHTML 2.0 ===
[10990950] |Between August 2002 and July 2006 the W3C released the first eight Working Drafts of XHTML 2.0, a new version of XHTML able to make a clean break from the past by discarding the requirement of backward compatibility.
[10990960] |This lack of compatibility with XHTML 1.x and HTML 4 caused some early controversy in the web developer community.
[10990970] |Some parts of the language (such as the role
and RDFa attributes) were subsequently split out of the specification and worked on as separate modules, partially to help make the transition from XHTML 1.x to XHTML 2.0 smoother.
[10990980] |A ninth draft of XHTML 2.0 is expected to appear in 2008.
[10990990] |New features introduced by XHTML 2.0 include:
[10991000] |* HTML forms will be replaced by [[XForms]], an XML-based user input specification allowing forms to be displayed appropriately for different rendering devices.
[10991010] |* HTML frames will be replaced by [[XFrames]].
[10991020] |* The [[DOM Events]] will be replaced by [[XML Events]], which uses the XML [[Document Object Model]].
[10991030] |* A new list element type, the nl
element type, will be included to specifically designate a list as a navigation list.
[10991040] |This will be useful in creating nested menus, which are currently created by a wide variety of means like nested unordered lists or nested definition lists.
[10991050] |* Any element will be able to act as a [[hyperlink]], e.g., Articles
, similar to [[XLink]].
[10991060] |However, XLink itself is not compatible with XHTML due to design differences.
[10991070] |* Any element will be able to reference alternative media with the src
attribute, e.g., London Bridge
is the same as
.
[10991080] |* The alt
attribute of the img
element has been removed: alternative text will be given in the content of the img
element, much like the object
element, e.g., HMS Audacious
.
[10991090] |* A single heading element (h
) will be added.
[10991100] |The level of these headings are determined by the depth of the nesting.
[10991110] |This allows the use of headings to be infinite, rather than limiting use to six levels deep.
[10991120] |* The remaining presentational elements i
, b
and tt
, still allowed in XHTML 1.x (even Strict), will be absent from XHTML 2.0.
[10991130] |The only somewhat presentational elements remaining will be sup
and sub
for superscript and subscript respectively, because they have significant non-presentational uses and are required by certain languages.
[10991140] |All other tags are meant to be [[semantic]] instead (e.g.
for strong or bolded text) while allowing the user agent to control the presentation of elements via CSS.
[10991150] |* The addition of RDF triple with the property
and about
attributes to facilitate the conversion from XHTML to RDF/XML.
[10991160] |=== HTML 5—Vocabulary and APIs for HTML and XHTML ===
[10991170] |[[HTML 5]] initially grew independently of the W3C, through a loose group of browser manufacturers and other interested parties calling themselves the [[WHATWG]], or Web Hypertext Application Technology Working Group.
[10991180] |The WHATWG announced the existence of an open mailing list in June 2004, along with a website bearing the strapline “Maintaining and evolving HTML since 2004.”
[10991190] |The key motive of the group was to create a platform for dynamic web applications; they considered XHTML 2.0 to be too document-centric, and not suitable for the creation of forum sites or online shops.
[10991200] |In April 2007, the Mozilla Foundation and Opera Software joined Apple in requesting that the newly rechartered HTML Working Group of the W3C adopt the work, under the name of HTML 5.
[10991210] |The group resolved to do this the following month, and the First Public Working Draft of HTML 5 was issued by the W3C in January 2008.
[10991220] |The most recent W3C Working Draft was published in June 2008.
[10991230] |HTML 5 has both a regular text/html
serialization and an XML serialization, which is known as XHTML 5.
[10991240] |In addition to the markup language, the specification includes a number of [[application programming interfaces]].
[10991250] |The [[Document Object Model]] is extended with APIs for editing, drag-and-drop, data storage and network communication.
[10991260] |The language can be considered more compatible with HTML 4 and XHTML 1.x than XHTML 2.0, due to the decision to keep the existing HTML form elements and events model.
[10991270] |It adds many new elements not found in XHTML 1.x, however, such as section
and aside
.
[10991280] |(The XHTML 1.2 equivalent of these structural elements would be
and
.)
[10991290] |The specification is expected to add WAI-ARIA support in a future draft.
[10991300] |There is currently no indication as to whether HTML 5 will support RDFa, or be limited just to [[microformats]].
[10991310] |== Valid XHTML documents ==
[10991320] |An XHTML document that conforms to an XHTML specification is said to be ''valid''.
[10991330] |Validity assures consistency in document code, which in turn eases processing, but does not necessarily ensure consistent rendering by browsers.
[10991340] |A document can be checked for validity with the [[W3C Markup Validation Service]].
[10991350] |In practice, many web development programs such as [[Dreamweaver]] provide code validation based on the [[W3C]] standards.
[10991360] |=== DOCTYPEs ===
[10991370] |In order to validate an XHTML document, a [[Document Type Declaration]], or ''DOCTYPE'', may be used.
[10991380] |A DOCTYPE declares to the browser which [[Document Type Definition]] (DTD) the document conforms to.
[10991390] |A Document Type Declaration should be placed before the [[root element]].
[10991400] |The [[system identifier]] part of the DOCTYPE, which in these examples is the [[Uniform Resource Locator|URL]] that begins with ''http://'', need only point to a copy of the DTD to use if the validator cannot locate one based on the [[public identifier]] (the other quoted string).
[10991410] |It does not need to be the specific URL that is in these examples; in fact, authors are encouraged to use local copies of the DTD files when possible.
[10991420] |The public identifier, however, must be character-for-character the same as in the examples.
[10991430] |These are the most common XHTML Document Type Declarations:
[10991440] |;XHTML 1.0 Strict
[10991450] |:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
[10991460] |;XHTML 1.0 Transitional
[10991470] |:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
[10991480] |;XHTML 1.0 Frameset
[10991490] |:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd ">
[10991500] |;XHTML 1.1
[10991510] |:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd ">
[10991520] |;HTML 5
[10991530] |HTML5 does not require a doctype, and HTML 5 validation is not DTD-based.
[10991540] |;XHTML 2.0
[10991550] |XHTML 2.0, [[As of April 2008]], is in a draft phase.
[10991560] |If an XHTML 2.0 Recommendation is published with the same document type declaration as in the current Working Draft, the declaration will appear as:
[10991570] |:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml2.dtd ">
[10991580] |A placeholder DTD schema exists at the corresponding URI, though it currently only includes the character reference entities from previous recommendations.
[10991590] |XHTML 2 contemplates both a version
attribute and an xsi:schemalocation
attribute on the root HTML element that could possibly serve as a substitute for any DOCTYPE declaration.
[10991600] |==== XML namespaces and schemas ====
[10991610] |In addition to the DOCTYPE, all XHTML elements must be in the appropriate [[XML namespace]] for the version being used.
[10991620] |This is usually done by declaring a default namespace on the root element using xmlns="namespace"
as in the example below.
[10991630] |For XHTML 1.0, XHTML 1.1 and HTML5, this is
[10991640] |:<html xmlns="http://www.w3.org/1999/xhtml" >
[10991650] |XHTML 2.0 requires both a namespace and an [[W3C XML Schema|XML Schema]] instance declaration.
[10991660] |These might be declared as
[10991670] |:<html xmlns="http://www.w3.org/2002/06/xhtml2/ "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "xsi:schemaLocation="http://www.w3.org/2002/06/xhtml2/ http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd ">
[10991680] |This example for XHTML 2.0 also demonstrates the use of multiple namespaces within a document.
[10991690] |The first xmlns
default namespace declaration indicates that elements and attributes whose names have no XML namespace prefix fall within the XHTML 2.0 namespace.
[10991700] |The second namespace prefix declaration xmlns:xsi
indicates that any elements or attributes prefixed with the xsi:
refer to the XMLSchema-Instance namespace.
[10991710] |Through this namespace mechanism XML documents allow the use of a mixture of elements and attributes taken from various XML vocabularies while avoiding the potential for clashes of naming between items from independently developed vocabularies.
[10991720] |Similar to the case of DOCTYPE above, the actual URL to the [[W3C XML Schema|XML Schema]] file can be changed, as long as the [[Universal Resource Identifier]] (URI) before it (which indicates the XHTML 2.0 namespace) remains the same.
[10991730] |The namespace URI is intended to be a persistent and universally unique identifier for the particular version of the specification.
[10991740] |If treated as a URL, the actual content located at the site is of no significance.
[10991750] |==== XML Declaration ====
[10991760] |A [[character encoding]] may be specified at the beginning of an XHTML document in the XML declaration when the document is served using the application/xhtml+xml
MIME type.
[10991770] |(If an XML document lacks encoding specification, an XML parser assumes that the encoding is [[UTF-8]] or [[UTF-16]], unless the encoding has already been determined by a higher protocol.)
[10991780] |For example:
[10991790] |:
[10991800] |The declaration may be optionally omitted because it declares as its encoding the default encoding.
[10991810] |However, if the document instead makes use of XML 1.1 or another character encoding, a declaration is necessary.
[10991820] |[[Internet Explorer]] prior to version 7 enters [[quirks mode]] if it encounters an XML declaration in a document served as text/html
.
[10991830] |=== Common errors ===
[10991840] |Some of the most common errors in the usage of XHTML are:
[10991850] |* Failing to realize that documents won’t be treated as XHTML unless they are served with an appropriate XML [[Internet media type|MIME type]]
[10991860] |* Not closing empty elements (elements without closing tags in HTML4)
[10991870] |** Incorrect:
[10991880] |** Correct:
[10991890] |Note that any of these are acceptable in XHTML: <br></br>
, <br/>
and <br />
.
[10991900] |Older HTML-only browsers interpreting it as HTML will generally accept <br>
and <br />
.
[10991910] |* Not closing non-empty elements
[10991920] |** Incorrect: This is a paragraph.
This is another paragraph.
[10991930] |** Correct: This is a paragraph.
This is another paragraph.
[10991940] |* Improperly nesting elements (Note that this would also be invalid in [[HTML]])
[10991950] |** Incorrect: This is some text.
[10991960] |** Correct: This is some text.
[10991970] |* Not putting quotation marks around attribute values
[10991980] |** Incorrect:
[10991990] |** Correct:
[10992000] |** Correct:
[10992010] |* Using the ampersand character outside of entities
[10992020] |** Incorrect: Cars & Trucks
[10992030] |** Correct: Cars & Trucks
[10992040] |* Using the ampersand outside of entities in [[Uniform Resource Locator|URL]]s (Note that this would also be invalid in [[HTML]])
[10992050] |** Incorrect: News
[10992060] |** Correct: News
[10992070] |* Failing to recognize that XHTML elements and attributes are case sensitive
[10992080] |** Incorrect: The Best Page Ever
[10992090] |** Correct: The Best Page Ever
[10992100] |* Using attribute minimization
[10992110] |** Incorrect:
[10992120] |** Correct:
[10992130] |* Mis-using CDATA, script-comments and xml-comments when embedding scripts and stylesheets.
[10992140] |** This problem can be avoided altogether by putting all script and stylesheet information into separate files and referring to them as follows in the XHTML head
element.
[10992150] | <link rel="stylesheet" href="/style/screen.css" type="text/css" /> <script type="text/javascript" src="/script/site.js"></script>
[10992160] |::Note: The format <script …></script>
, rather than the more concise <script … />
, is required for HTML compatibility when served as MIME type text/html
.
[10992170] |** If an author chooses to include script or style data inline within an XHTML document, different approaches are recommended depending whether the author intends to serve the page as application/xhtml+xml
and target only fully conformant browsers, or serve the page as text/html
and try to obtain usability in Internet Explorer 6 and other non-conformant browsers.
[10992180] |== Backward compatibility ==
[10992190] |XHTML 1.x documents are mostly backward compatible with HTML 4 user agents when the appropriate guidelines are followed.
[10992200] |XHTML 1.1 is essentially compatible, although the elements for [[ruby character|ruby annotiation]] are not part of the HTML 4 specification and thus generally ignored by HTML 4 browsers.
[10992210] |Later XHTML 1.x modules such as those for the role
attribute, [[RDFa]] and [[WAI-ARIA]] degrade gracefully in a similar manner.
[10992220] |HTML 5 and XHTML 2 are significantly less compatible, although this can be mitigated to some degree through the use of scripting.
[10992230] |(This can be simple one-liners, such as the use of “document.createElement()
” to register a new HTML element within Internet Explorer, or complete JavaScript frameworks, such as the [[FormFaces]] implementation of [[XForms]].)
[10992240] |=== Examples ===
[10992250] |The followings are examples of XHTML 1.0 Strict.
[10992260] |Both of them have the same visual output.
[10992270] |The former one follows the [http://www.w3.org/TR/xhtml1/#guidelines HTML Compatibility Guidelines] in Appendix C of the XHTML 1.0 Specification while the latter one breaks backward compatibility but provides cleaner codes.
[10992280] |Example 1.
[10992290] |Example 2.
[10992300] |Notes:
[10992310] |# For further information on the media type recommendation, please refer to [http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801/ XHTML Media Types], a W3C Note issued on 2002-08-01.
[10992320] |# The "loadpdf" function is actually a workaround for Internet Explorer.
[10992330] |It can be replaced by adding
within
.
[10992340] |# The img
element does not get a name
attribute in the [http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict XHTML 1.0 Strict DTD].
[10992350] |Use id
instead.
[11000010] |XML
[11000020] |The '''Extensible Markup Language''' ('''XML''') is a general-purpose ''specification'' for creating custom [[markup language]]s.
[11000030] |It is classified as an [[extensible language]] because it allows its users to define their own elements.
[11000040] |Its primary purpose is to facilitate the sharing of structured data across different information systems, particularly via the [[Internet]], and it is used both to encode documents and to [[Serialization|serialize]] data.
[11000050] |In the latter context, it is comparable with other text-based serialization languages such as [[JSON]] and [[YAML]].
[11000060] |It started as a simplified subset of the [[Standard Generalized Markup Language]] (SGML), and is designed to be relatively human-legible.
[11000070] |By adding [[semantics|semantic]] constraints, application languages can be implemented in XML.
[11000080] |These include [[XHTML]], [[RSS (file format)|RSS]], [[MathML]], [[GraphML]], [[Scalable Vector Graphics]], [[MusicXML]], and thousands of others.
[11000090] |Moreover, XML is sometimes used as the [[specification language]] for such application languages.
[11000100] |XML is [[W3C recommendation|recommended]] by the [[World Wide Web Consortium]] (W3C).
[11000110] |It is a fee-free [[open standard]].
[11000120] |The recommendation specifies both the [[lexical grammar]] and the requirements for [[parsing]].
[11000130] |==Well-formed and valid XML documents==
[11000140] |There are two levels of correctness of an XML document:
[11000150] |* '''Well-formed'''.
[11000160] |A well-formed document conforms to all of XML's syntax rules.
[11000170] |For example, if a start-tag appears without a corresponding end-tag, it is not ''well-formed''.
[11000180] |A document that is not well-formed is not considered to be XML; a ''conforming parser'' is not allowed to process it.
[11000190] |* '''Valid'''.
[11000200] |A valid document additionally conforms to some semantic rules.
[11000210] |These rules are either user-defined, or included as an [[XML schema]] or [[Document Type Definition|DTD]].
[11000220] |For example, if a document contains an undefined element, then it is not ''valid''; a ''validating parser'' is not allowed to process it.
[11000230] |==Well-formed documents: XML syntax==
[11000240] |As long as only [[well-formed element|well-formedness]] is required, XML is a generic framework for storing any amount of text or any data whose structure can be represented as a [[Tree (data structure)|tree]].
[11000250] |The only indispensable syntactical requirement is that the document has exactly one '''root element''' (alternatively called the '''document element''').
[11000260] |This means that the text must be enclosed between a root start-tag and a corresponding end-tag.
[11000270] |The following is a "well-formed" XML document:
[11000280] |The root element can be preceded by an optional '''XML declaration'''.
[11000290] |This element states what version of XML is in use (normally 1.0); it may also contain information about [[character encoding]] and external dependencies.
[11000300] |The specification ''requires'' that [[Data Processor|processors]] of XML support the pan-[[Unicode]] [[character encoding]]s [[UTF-8]] and [[UTF-16/UCS-2|UTF-16]] ([[UTF-32/UCS-4|UTF-32]] is not mandatory).
[11000310] |The use of more limited encodings, such as those based on [[ISO/IEC 8859]], is acknowledged and is widely used and supported.
[11000320] |'''Comments''' can be placed anywhere in the tree, including in the text if the content of the element is text or #PCDATA.
[11000330] |XML comments start with '''<!--''' and end with '''-->'''.
[11000340] |Two dashes (--) may not appear anywhere in the text of the comment.
[11000350] |
[11000360] |In any meaningful application, additional markup is used to structure the contents of the XML document.
[11000370] |The text enclosed by the root tags may contain an arbitrary number of XML elements.
[11000380] |The basic syntax for one '''element''' is: The two instances of »name« are referred to as the '''start-tag''' and '''end-tag''', respectively.
[11000390] |Here, »content« is some text which may again contain XML elements.
[11000400] |So, a generic XML document contains a [[tree (data structure)|tree-based data structure]].
[11000410] |Here is an example of a structured XML document:
[11000420] |
[11000430] |Attribute values must always be quoted, using single or double quotes; and each attribute name must appear only once in any element.
[11000440] |XML requires that elements be properly nested — elements may never overlap, and so must be closed in the opposite order to which they are opened.
[11000450] |For example, this fragment of code below cannot be part of a well-formed XML document because the ''title'' and ''author'' elements are closed in the wrong order: One way of writing the same information in a way which could be incorporated into a well-formed XML document is as follows:
[11000460] |XML provides special syntax for representing an element with empty content.
[11000470] |Instead of writing a start-tag followed immediately by an end-tag, a document may contain an empty-element tag.
[11000480] |An empty-element tag resembles a start-tag but contains a slash just before the closing angle bracket.
[11000490] |The following three examples are equivalent in XML: An empty-element may contain attributes:
[11000500] |===Entity references===
[11000510] |An [[SGML entity|entity]] in XML is a named body of data, usually text.
[11000520] |Entities are often used to represent single characters that cannot easily be entered on the keyboard; they are also used to represent pieces of standard ("boilerplate") text that occur in many documents, especially if there is a need to allow such text to be changed in one place only.
[11000530] |Special characters can be represented either using [[SGML entity|entity]] references, or by means of [[numeric character reference]]s.
[11000540] |An example of a numeric character reference is "€
", which refers to the [[Euro symbol]] by means of its [[Unicode]] codepoint in [[hexadecimal]].
[11000550] |An entity reference is a [[placeholder]] that represents that entity.
[11000560] |It consists of the entity's name preceded by an [[ampersand]] ("&
") and followed by a [[semicolon]] (";
").
[11000570] |XML has five [[predeclared]] entities:
[11000580] |* &
(& or "ampersand")
[11000590] |* <
(< or "less than")
[11000600] |* >
(> or "greater than")
[11000610] |* '
(' or "apostrophe")
[11000620] |* "
(" or "quotation mark")
[11000630] |Here is an example using a predeclared XML entity to represent the ampersand in the name "AT&T": Additional entities (beyond the predefined ones) can be declared in the document's [[XML#DTD|Document Type Definition (DTD)]].
[11000640] |A basic example of doing so in a minimal internal DTD follows.
[11000650] |Declared entities can describe single characters or pieces of text, and can reference each other.
[11000660] |When viewed in a suitable browser, the XML document above appears as:
[11000670] |Copyright © 2006, XYZ Enterprises
[11000680] |====Numeric character references====
[11000690] |Numeric character references look like entity references, but instead of a name, they contain the "[[number sign|#]]
" character followed by a number.
[11000700] |The number (in decimal or "x
"-prefixed [[hexadecimal]]) represents a Unicode code point.
[11000710] |Unlike entity references, they are neither predeclared nor do they need to be declared in the document's DTD.
[11000720] |They have typically been used to represent characters that are not easily encodable, such as an [[Arabic language|Arabic]] character in a document produced on a European computer.
[11000730] |The ampersand in the "AT&T" example could also be [[escape character|escaped]] like this (decimal 38 and hexadecimal 26 both represent the Unicode code point for the "&" character):
[11000740] |Similarly, in the previous example, notice that “©” is used to generate the “©” symbol.
[11000750] |See also [[numeric character reference]]s.
[11000760] |===Well-formed documents===
[11000770] |In XML, a [[well-formed element|well-formed]] document must conform to the following rules, among others:
[11000780] |* Non-empty elements are [[delimiter|delimited]] by both a start-tag and an end-tag.
[11000790] |* Empty elements may be marked with an empty-element (self-closing) tag, such as <IAmEmpty />
.
[11000800] |This is equal to <IAmEmpty></IAmEmpty>
.
[11000810] |* All attribute values are quoted with either single (') or double (") quotes.
[11000820] |Single quotes close a single quote and double quotes close a double quote.
[11000830] |* Tags may be nested but must not overlap.
[11000840] |Each non-root element must be completely contained in another element.
[11000850] |* The document complies with its declared character encoding.
[11000860] |The encoding may be declared or implied externally, such as in "Content-Type" headers when a document is transported via [[Hypertext Transfer Protocol|HTTP]], or internally, using explicit markup at the very beginning of the document.
[11000870] |When no such declaration exists, a Unicode encoding is assumed, as defined by a Unicode [[Byte-order mark|Byte Order Mark]] before the document's first character.
[11000880] |If the mark does not exist, UTF-8 encoding is assumed.
[11000890] |Element names are case-sensitive.
[11000900] |For example, the following is a well-formed matching pair:
[11000910] |:<Step>
... </Step>
[11000920] |whereas this is not
[11000930] |:<Step>
... </step>
[11000940] |By carefully choosing the names of the XML elements one may convey the meaning of the data in the [[Markup language|markup]].
[11000950] |This increases human readability while retaining the rigor needed for software parsing.
[11000960] |Choosing meaningful names implies the [[semantics]] of elements and attributes to a human reader without reference to external documentation.
[11000970] |However, this can lead to verbosity, which complicates [[authoring]] and increases [[file size]].
[11000980] |===Automatic verification===
[11000990] |It is relatively simple to verify that a document is well-formed or validated XML, because the rules of well-formedness and validation of XML are designed for portability of tools.
[11001000] |The idea is that any tool designed to work with XML files will be able to work with XML files written in any XML language (or XML application).
[11001010] |Here are some examples of ways to verify XML documents:
[11001020] |* load it into an XML-capable browser, such as [[Mozilla Firefox|Firefox]] or [[Internet Explorer]]
[11001030] |* use a tool like xmlwf (usually bundled with [[Expat (XML)|expat]])
[11001040] |* parse the document, for instance in [[Ruby programming language|Ruby]]:
[11001050] |irb> require "rexml/document" irb> include REXML irb> doc = Document.new(File.new("test.xml")).root
[11001060] |==Valid documents: XML semantics==
[11001070] |By leaving the names, allowable hierarchy, and meanings of the elements and attributes open and definable by a customizable ''[[XML schema|schema]] or [[Document Type Definition|DTD]]'', XML provides a syntactic foundation for the creation of purpose-specific, XML-based markup languages.
[11001080] |The general syntax of such languages is rigid — documents must adhere to the general rules of XML, ensuring that all XML-aware software can at least read and understand the relative arrangement of information within them.
[11001090] |The schema merely supplements the syntax rules with a set of constraints.
[11001100] |Schemas typically restrict element and attribute names and their allowable containment hierarchies, such as only allowing an element named 'birthday' to contain one element named 'month' and one element named 'day', each of which has to contain only character data.
[11001110] |The constraints in a schema may also include [[data type]] assignments that affect how information is processed; for example, the 'month' element's character data may be defined as being a month according to a particular schema language's conventions, perhaps meaning that it must not only be formatted a certain way, but also must not be processed as if it were some other type of data.
[11001120] |An XML document that complies with a particular schema/DTD, in addition to being well-formed, is said to be '''valid'''.
[11001130] |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.
[11001140] |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.
[11001150] |Before the advent of generalised data description languages such as SGML and XML, software designers had to define special [[file format]]s or small languages to share data between programs.
[11001160] |This required writing detailed [[specifications]] and special-purpose parsers and [[writer]]s.
[11001170] |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.
[11001180] |Well-tested tools exist to [[validate]] an XML document "against" a schema: the tool automatically [[verify|verifies]] whether the document conforms to constraints expressed in the schema.
[11001190] |Some of these validation tools are included in XML parsers, and some are packaged separately.
[11001200] |Other usages of schemas exist: XML editors, for instance, can use schemas to support the editing process (by suggesting valid elements and attributes names, etc).
[11001210] |====DTD====
[11001220] |The oldest schema format for XML is the [[Document Type Definition]] (DTD), inherited from SGML.
[11001230] |While DTD support is ubiquitous due to its inclusion in the XML 1.0 standard, it is seen as limited for the following reasons:
[11001240] |* It has no support for newer [[feature]]s of XML, most importantly [[XML Namespace|namespaces]].
[11001250] |* It lacks expressiveness.
[11001260] |Certain formal aspects of an XML document cannot be captured in a DTD.
[11001270] |* It uses a custom non-XML syntax, inherited from [[SGML]], to describe the schema.
[11001280] |DTD is still used in many applications because it is considered the easiest to read and write.
[11001290] |====XML Schema====
[11001300] |A newer [[XML schema]] language, described by the W3C as the successor of DTDs, is [[XML Schema (W3C)|XML Schema]], or more informally referred to by the [[acronym and initialism|initialism]] for XML Schema instances, XSD (XML Schema Definition).
[11001310] |XSDs are far more powerful than DTDs in describing XML languages.
[11001320] |They use a rich [[datatype|datatyping]] system, allow for more detailed constraints on an XML document's logical structure, and must be processed in a more robust validation framework.
[11001330] |XSDs also use an XML-based format, which makes it possible to use ordinary XML tools to help process them, although XSD implementations require much more than just the ability to read XML.
[11001340] |Criticisms of XSD include the following:
[11001350] |*The specification is very large, which makes it difficult to understand and implement.
[11001360] |*The XML-based syntax leads to verbosity in schema descriptions, which makes XSDs harder to read and write.
[11001370] |*Schema validation can be an expensive addition to XML parsing, especially for high volume systems.
[11001380] |*The modeling capabilities are very limited, with no ability to allow attributes to influence [[content model]]s.
[11001390] |*The [[type derivation model]] is very limited, in particular that derivation by extension is rarely useful.
[11001400] |*Database-related [[data transfer]] is supported with ideas such as [[nillability]], but the requirements of industrial publishing are under-supported.
[11001410] |*The key/[[keyref]]/[[uniqueness]] mechanisms are not type-aware.
[11001420] |*The [[PSVI]] concept (Post Schema Validation Infoset) does not have a standard XML representation or [[Application Programming Interface]], thus it works against [[vendor independence]] unless revalidation is performed.
[11001430] |====RELAX NG====
[11001440] |Another popular schema language for XML is [[RELAX NG]].
[11001450] |Initially specified by [[OASIS (organization)|OASIS]], RELAX NG is now also an ISO international standard (as part of [[DSDL]]).
[11001460] |It has two formats: an XML based syntax and a non-XML compact syntax.
[11001470] |The compact syntax aims to increase readability and writability but, since there is a well-defined way to translate the compact syntax to the XML syntax and back again by means of [[James Clark (XML expert)|James Clark]]'s [http://www.thaiopensource.com/relaxng/trang.html Trang conversion tool], the advantage of using standard XML tools is not lost.
[11001480] |RELAX NG has a simpler definition and validation framework than XML Schema, making it easier to use and implement.
[11001490] |It also has the ability to use [[datatype]] framework [[plug-in]]s; a RELAX NG schema author, for example, can require values in an XML document to conform to definitions in XML Schema Datatypes.
[11001500] |====ISO DSDL and other schema languages====
[11001510] |The ISO [[DSDL]] (Document Schema Description Languages) standard brings together a comprehensive set of small schema languages, each targeted at specific problems.
[11001520] |DSDL includes [[RELAX NG]] full and compact syntax, [[Schematron]] assertion language, and languages for defining datatypes, character repertoire constraints, renaming and entity expansion, and namespace-based [[routing]] of document fragments to different validators.
[11001530] |DSDL schema languages do not have the vendor support of XML Schemas yet, and are to some extent a grassroots reaction of industrial publishers to the lack of utility of XML Schemas for [[publishing]].
[11001540] |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.
[11001550] |DTDs and XSDs both have this ability; they can for instance provide attribute defaults.
[11001560] |RELAX NG and Schematron intentionally do not provide these; for example the [[infoset]] augmentation facility.
[11001570] |=== International use ===
[11001580] |XML supports the direct use of almost any Unicode character in element names, attributes, comments, character data, and processing instructions (other than the ones that have special symbolic meaning in XML itself, such as the open corner bracket, "<").
[11001590] |Therefore, the following is a well-formed XML document, even though it includes both [[Chinese character|Chinese]] and [[Cyrillic alphabet|Cyrillic]] characters:
[11001600] |== Displaying XML on the web ==
[11001610] |XML documents do not carry information about how to display the data.
[11001620] |Without using [[Cascading Style Sheets|CSS]] or [[Extensible Stylesheet Language|XSL]], a generic XML document is rendered as raw XML text by most [[web browser]]s.
[11001630] |Some display it with 'handles' (e.g. + and - signs in the margin) that allow parts of the structure to be expanded or collapsed with mouse-clicks.
[11001640] |In order to style the rendering in a browser with CSS, the XML document must include a reference to the [[stylesheet]]:
[11001650] |Note that this is different from specifying such a stylesheet in HTML, which uses the <link>
element.
[11001660] |[[Extensible Stylesheet Language]] (XSL) can be used to alter the format of XML data, either into HTML or other formats that are suitable for a browser to display.
[11001670] |To specify [[client-side]] [[XSL Transformations|XSL Transformation]] (XSLT), the following processing instruction is required in the XML:
[11001680] |Client-side XSLT is supported by many [[web browser]]s.
[11001690] |Alternatively, one may use XSL to convert XML into a displayable format ''on the [[Server (computing)|server]]'' rather than being dependent on the [[end-user]]'s browser capabilities.
[11001700] |The end-user is not aware of what has gone on 'behind the scenes'; all they see is well-formatted, displayable data.
[11001710] |See the XSLT article for [[XSL Transformations#XSLT examples|an example of server-side XSLT in action]].
[11001720] |== XML extensions ==
[11001730] |* '''[[XPath]]''' makes it possible to refer to individual parts of an XML document.
[11001740] |This provides random access to XML data for other technologies, including XSLT, XSL-FO, XQuery etc.
[11001750] |XPath expressions can refer to all or part of the text, data and values in XML elements, attributes, processing instructions, comments etc.
[11001760] |They can also access the names of elements and attributes.
[11001770] |XPaths can be used in both valid and well-formed XML, with and without defined namespaces.
[11001780] |*'''[[XInclude]]''' defines the ability for XML files to include all or part of an external file.
[11001790] |When processing is complete, the final XML infoset has no XInclude elements, but instead has copied the documents or parts thereof into the final infoset.
[11001800] |It uses XPath to refer to a portion of the document for partial inclusions.
[11001810] |*'''[[XQuery]]''' is to XML and [[XML database|XML Databases]] what [[SQL]] and [[PL/SQL]] are to [[relational databases]]: ways to access, manipulate and return XML.
[11001820] |*'''[[XML Namespace]]s''' enable the same document to contain XML elements and attributes taken from different vocabularies, without any [[naming collision]]s occurring.
[11001830] |*'''[[XML Signature]]''' defines the syntax and processing rules for creating [[digital signatures]] on XML content.
[11001840] |*'''[[XML Encryption]]''' defines the syntax and processing rules for [[encryption|encrypting]] XML content.
[11001850] |* '''[[XPointer]]''' is a system for addressing components of XML-based internet media.
[11001860] |XML files may be served with a variety of [[MIME|Media types]].
[11001870] |RFC 3023 defines the types "application/xml" and "text/xml", which say only that the data is in XML, and nothing about its semantics.
[11001880] |The use of "text/xml" has been criticized as a potential source of encoding problems but is now in the process of being deprecated.
[11001890] |RFC 3023 also recommends that XML-based languages be given media types beginning in "application/" and ending in "+xml"; for example "application/atom+xml" for [[Atom (standard)|Atom]].
[11001900] |This page discusses further [[XML and MIME]].
[11001910] |== Processing XML files ==
[11001920] |Three traditional techniques for processing XML files are:
[11001930] |* Using a programming language and the [[Simple API for XML|SAX]] [[Application programming interface|API]].
[11001940] |* Using a programming language and the [[DOM (XML API)|DOM]] [[Application programming interface|API]].
[11001950] |* Using a transformation engine and a filter
[11001960] |More recent and emerging techniques for processing XML files are:
[11001970] |* Pull Parsing
[11001980] |* Non-Extractive Parsing (i.e. in-situ parsing)
[11001990] |* Data binding
[11002000] |=== Simple API for XML (SAX)===
[11002010] |[[Simple API for XML|SAX]] is a [[lexical analysis|lexical]], [[Event-driven programming|event-driven]] interface in which a document is read serially and its contents are reported as "[[callback]]s" to various [[method (computer science)|method]]s on a [[event handler|handler object]] of the user's design.
[11002020] |SAX is fast and efficient to implement, but difficult to use for extracting information at random from the XML, since it tends to burden the application author with keeping track of what part of the document is being processed.
[11002030] |It is better suited to situations in which certain types of information are always handled the same way, no matter where they occur in the document.
[11002040] |=== DOM ===
[11002050] |[[Document Object Model|DOM]] is an [[interface]]-oriented [[Application Programming Interface]] that allows for navigation of the entire document as if it were a tree of "[[Node (computer science)|Node]]" [[Object (computer science)|object]]s representing the document's contents.
[11002060] |A DOM document can be created by a parser, or can be generated manually by users (with limitations).
[11002070] |Data types in DOM Nodes are abstract; implementations provide their own [[programming]] language-specific [[binding]]s.
[11002080] |DOM implementations tend to be [[memory]] intensive, as they generally require the entire document to be loaded into memory and constructed as a tree of objects before access is allowed.
[11002090] |DOM is supported in Java by several packages that usually come with the standard libraries.
[11002100] |As the DOM specification is regulated by the [[World Wide Web Consortium]], the main interfaces (Node, Document, etc.) are in the package org.w3c.dom.*, as well as some of the events and interfaces for other capabilities like serialization (output).
[11002110] |The package com.sun.org.apache.xml.internal.serialize.* provides the serialization (output capacities) by implementing the appropriate interfaces, while the javax.xml.parsers.* package parses data to create DOM XML documents for manipulation.
[11002120] |=== Non-extractive XML Processing API ===
[11002130] |Non-extractive XML Processing API is a new and emerging category of parsers that aim to overcome the fundamental limitations of DOM and SAX.
[11002140] |The most representative is VTD-XML, which abolishes the object-oriented modeling of XML hierarchy and instead uses 64-bit Virtual Token Descriptors (encoding offsets, lengths, depths, and types) of XML tokens.
[11002150] |VTD-XML's approach enables a number of interesting features/enhancements, such as high performance, low memory usage [8], ASIC implementation [9], incremental update [10], and native XML indexing [11] [12].
[11002160] |=== Transformation engines and filters ===
[11002170] |A [[filter (software)|filter]] in the [[Extensible Stylesheet Language]] (XSL) family can transform an XML file for [[display]]ing or [[Computer printer|print]]ing.
[11002180] |* '''[[XSL-FO]]''' is a declarative, XML-based [[page layout]] language.
[11002190] |An XSL-FO processor can be used to convert an XSL-FO document into another non-XML format, such as [[PDF]].
[11002200] |* '''[[XSLT]]''' is a declarative, XML-based document transformation language.
[11002210] |An XSLT processor can use an XSLT ''stylesheet'' as a guide for the conversion of the data tree represented by one XML document into another tree that can then be [[serialize]]d as XML, HTML, plain text, or any other format supported by the processor.
[11002220] |* '''[[XQuery]]''' is a W3C language for [[query]]ing, constructing and transforming XML data.
[11002230] |* '''[[XPath]]''' is a DOM-like node tree [[data model]] and [[path expression]] language for selecting data within XML documents.
[11002240] |XSL-FO, XSLT and XQuery all make use of XPath.
[11002250] |XPath also includes a useful [[function library]].
[11002260] |=== Pull parsing ===
[11002270] |Pull parsing treats the document as a series of items which are read in sequence using the Iterator design pattern.
[11002280] |This allows for writing of [[recursive descent parser|recursive-descent parsers]] in which the structure of the code performing the parsing mirrors the structure of the XML being parsed, and intermediate parsed results can be used and accessed as local variables within the methods performing the parsing, or passed down (as method parameters) into lower-level methods, or returned (as method return values) to higher-level methods.
[11002290] |Examples of pull parsers include [[StAX]] in the [[Java (programming language)|Java]] programming language, SimpleXML in PHP and System.Xml.XmlReader in .NET.
[11002300] |A pull parser creates an iterator that sequentially visits the various elements, attributes, and data in an XML document.
[11002310] |Code which uses this 'iterator' can test the current item (to tell, for example, whether it is a start or end element, or text), and inspect its attributes (local name, namespace, values of XML attributes, value of text, etc.), and can also move the iterator to the 'next' item.
[11002320] |The code can thus extract information from the document as it traverses it.
[11002330] |The recursive-descent approach tends to lend itself to keeping data as typed local variables in the code doing the parsing, while SAX, for instance, typically requires a parser to manually maintain intermediate data within a stack of elements which are parent elements of the element being parsed.
[11002340] |Pull-parsing code can be more straightforward to understand and maintain than SAX parsing code.
[11002350] |=== Non-extractive XML Processing API ===
[11002360] |Non-extractive XML Processing API is a new and emerging category of parsers that aim to overcome the fundamental limitations of DOM and SAX.
[11002370] |The most representative is [[VTD-XML]], which abolishes the object-oriented modeling of XML hierarchy and instead uses 64-bit Virtual Token Descriptors (encoding offsets, lengths, depths, and types) of XML tokens.
[11002380] |VTD-XML's approach enables a number of interesting features/enhancements, such as high performance, low memory usage , ASIC implementation , incremental update , and native XML indexing .
[11002390] |=== Data binding ===
[11002400] |Another form of XML Processing API is [[XML data binding|data binding]], where XML data is made available as a custom, strongly typed programming language data structure, in contrast to the interface-oriented DOM.
[11002410] |Example data binding systems include the [[Java (programming language)|Java]] [[Architecture]] for XML Binding ([[JAXB]]).
[11002420] |=== Specific XML applications and editors ===
[11002430] |The [[Native and foreign format|native file format]] of [[OpenOffice.org]], [[AbiWord]], and [[Apple Computer|Apple]]'s [[iWork]] applications is XML.
[11002440] |Some parts of [[Microsoft Office]] 2007 are also able to edit XML files with a user-supplied schema (but not a DTD), and Microsoft has released a file format compatibility kit for Office 2003 that allows previous versions of Office to save in the new XML based format.
[11002450] |There are dozens of other [[XML editor]]s available.
[11002460] |==History==
[11002470] |The versatility of [[SGML]] for dynamic information display was understood by early digital media publishers in the late 1980s prior to the rise of the Internet.
[11002480] |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.
[11002490] |[[Dan Connolly]] added SGML to the list of W3C's activities when he joined the staff in 1995; work began in mid-1996 when [[Jon Bosak]] developed a charter and recruited collaborators.
[11002500] |Bosak was well connected in the small community of people who had experience both in SGML and the Web.
[11002510] |He received support in his efforts from [[Microsoft]].
[11002520] |XML was compiled by a [[working group]] of eleven members, supported by an (approximately) 150-member Interest Group.
[11002530] |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.
[11002540] |A record of design decisions and their rationales was compiled by [[Michael Sperberg-McQueen]] on December 4th 1997.
[11002550] |[[James Clark (XML expert)|James Clark]] served as Technical Lead of the Working Group, notably contributing the empty-element " " syntax and the name "XML".
[11002560] |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).
[11002570] |The co-editors of the specification were originally [[Tim Bray]] and [[Michael Sperberg-McQueen]].
[11002580] |Halfway through the project Bray accepted a consulting engagement with [[Netscape Communications Corporation|Netscape]], provoking vociferous protests from Microsoft.
[11002590] |Bray was temporarily asked to resign the editorship.
[11002600] |This led to intense dispute in the Working Group, eventually solved by the appointment of Microsoft's [[Jean Paoli]] as a third co-editor.
[11002610] |The XML Working Group never met face-to-face; the design was accomplished using a combination of email and weekly teleconferences.
[11002620] |The major design decisions were reached in twenty weeks of intense work between July and November of 1996, when the first Working Draft of an XML specification was published.
[11002630] |Further design work continued through [[1997]], and XML 1.0 became a [[W3C]] Recommendation on [[February 10]], [[1998]].
[11002640] |XML 1.0 achieved the Working Group's goals of Internet usability, general-purpose usability, SGML compatibility, facilitation of easy development of processing software, minimization of optional features, legibility, formality, conciseness, and ease of authoring.
[11002650] |Like its antecedent SGML, XML allows for some redundant syntactic constructs and includes repetition of element identifiers.
[11002660] |In these respects, terseness was not considered essential in its structure.
[11002670] |===Sources===
[11002680] |XML is a profile of an ISO standard [[SGML]], and most of XML comes from SGML unchanged.
[11002690] |From SGML comes the separation of logical and physical structures (elements and entities), the availability of grammar-based validation (DTDs), the separation of data and metadata (elements and attributes), mixed content, the separation of processing from representation (processing instructions), and the default angle-bracket syntax.
[11002700] |Removed were the SGML Declaration (XML has a fixed delimiter set and adopts [[Unicode]] as the document [[Character encoding|character set]]).
[11002710] |Other sources of technology for XML were the [[Text Encoding Initiative]] (TEI), which defined a profile of SGML for use as a 'transfer syntax'; [[HTML]], in which elements were synchronous with their resource, the separation of document character set from resource encoding, the xml:lang attribute, and the [[HTTP]] notion that metadata accompanied the resource rather than being needed at the declaration of a link; and the Extended Reference Concrete Syntax (ERCS), from which XML 1.0's naming rules were taken, and which had introduced hexadecimal numeric character references and the concept of references to make available all Unicode characters.
[11002720] |Ideas that developed during discussion which were novel in XML, were the algorithm for encoding detection and the encoding header, the processing instruction target, the xml:space attribute, and the new close delimiter for empty-element tags.
[11002730] |===Versions===
[11002740] |There are two current versions of XML.
[11002750] |The first, ''XML 1.0'', was initially defined in [[1998]].
[11002760] |It has undergone minor revisions since then, without being given a new version number, and is currently in its fourth edition, as published on [[August 16]], [[2006]].
[11002770] |It is widely implemented and still recommended for general use.
[11002780] |The second, ''XML 1.1'', was initially published on [[February 4]], [[2004]], the same day as XML 1.0 Third Edition, and is currently in its second edition, as published on [[August 16]], [[2006]].
[11002790] |It contains features — some contentious — that are intended to make XML easier to use in certain cases - mainly enabling the use of line-ending characters used on [[EBCDIC]] platforms, and the use of scripts and characters absent from Unicode 2.0.
[11002800] |XML 1.1 is not very widely implemented and is recommended for use only by those who need its unique features.
[11002810] |XML 1.0 and XML 1.1 differ in the requirements of characters used for element and attribute names: XML 1.0 only allows characters which are defined in Unicode 2.0, which includes most world scripts, but excludes those which were added in later Unicode versions.
[11002820] |Among the excluded scripts are [[Mongolian language|Mongolian]], [[Cambodian language|Cambodian]], [[Amharic]], [[Burmese language|Burmese]], and others.
[11002830] |Almost any Unicode character can be used in the character data and attribute values of an XML 1.1 document, even if the character is not defined, aside from having a code point, in the current version of Unicode.
[11002840] |The approach in XML 1.1 is that only certain characters are forbidden, and everything else is allowed, whereas in XML 1.0, only certain characters are explicitly allowed, thus XML 1.0 cannot accommodate the addition of characters in future versions of Unicode.
[11002850] |In character data and attribute values, XML 1.1 allows the use of more [[control character]]s than XML 1.0, but, for "robustness", most of the control characters introduced in XML 1.1 must be expressed as numeric character references.
[11002860] |Among the supported control characters in XML 1.1 are two line break codes that must be treated as whitespace.
[11002870] |Whitespace characters are the only control codes that can be written directly.
[11002880] |There are also discussions on an XML 2.0, although it remains to be seen if such will ever come about. [http://www.textuality.com/xml/xmlSW.html 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 [[namespace (computer science)#XML|namespace]]s, [[XML Base]] and [[XML Information Set]] (''infoset'') into the base standard.
[11002890] |The World Wide Web Consortium also has an XML Binary Characterization Working Group doing preliminary research into use cases and properties for a binary encoding of the XML infoset.
[11002900] |The working group is not chartered to produce any official standards.
[11002910] |Since XML is by definition text-based, ITU-T and ISO are using the name ''[[Fast Infoset]][http://asn1.elibel.tm.fr/xml/finf.htm]'' for their own binary infoset to avoid confusion (see ITU-T Rec. X.891 | ISO/IEC 24824-1).
[11002920] |===Patent claims===
[11002930] |In October 2005 the small company [[Scientigo]] publicly asserted that two of its patents, and , apply to the use of XML.
[11002940] |The patents cover the "modeling, storage and transfer [of data] in a particular ''non-hierarchical'', non-integrated neutral form", according to their applications, which were filed in 1997 and 1999.
[11002950] |Scientigo CEO [[Doyal Bryant]] expressed a desire to "monetize" the patents but stated that the company was "not interested in having us against the world."
[11002960] |He said that Scientigo was discussing the patents with several large corporations.
[11002970] |XML users and independent experts responded to Scientigo's claims with widespread skepticism and criticism.
[11002980] |Some derided the company as a [[patent troll]].
[11002990] |[[Tim Bray]] described any claims that the patents covered XML as "ridiculous on the face of it".
[11003000] |== Critique of XML ==
[11003010] |Commentators have offered various critiques of XML, suggesting circumstances where XML provides both advantages and potential disadvantages.
[11003020] |===Advantages of XML===
[11003030] |* It is text-based.
[11003040] |* It supports [[Unicode]], allowing almost any information in any written human language to be communicated.
[11003050] |* It can represent common [[computer science]] [[data structure]]s: [[record (computer science)|record]]s, [[List (computing)|list]]s and [[tree data structure|tree]]s.
[11003060] |* Its [[self-documenting]] format describes [[structure]] and [[field name]]s as well as specific values.
[11003070] |* The strict [[syntax]] and [[parsing]] requirements make the necessary [[parser|parsing algorithms]] extremely simple, efficient, and consistent.
[11003080] |* XML is heavily used as a format for [[document storage]] and processing, both online and offline.
[11003090] |* It is based on [[international standards]].
[11003100] |* It can be updated incrementally.
[11003110] |* It allows validation using schema languages such as [[XSD]] and [[Schematron]], which makes effective unit-testing, firewalls, acceptance testing, contractual specification and software construction easier.
[11003120] |* The [[hierarchy|hierarchical]] structure is suitable for most (but not all) types of documents.
[11003130] |* It is platform-independent, thus relatively immune to changes in technology.
[11003140] |* Forward and backward compatibility are relatively easy to maintain despite changes in DTD or Schema.
[11003150] |* Its predecessor, [[SGML]], has been in use since [[1986]], so there is extensive experience and software available.
[11003160] |===Disadvantages of XML===
[11003170] |* XML syntax is redundant or large relative to binary representations of similar data, especially with [[Table (information)|tabular]] data.
[11003180] |* The redundancy may affect application efficiency through higher storage, transmission and processing costs.
[11003190] |* XML syntax is verbose, especially for human readers, relative to other alternative 'text-based' data transmission formats.
[11003200] |* The [[hierarchical model]] for representation is limited in comparison to an [[object oriented]] [[Graph (mathematics)|graph]].
[11003210] |* Expressing overlapping (non-hierarchical) node relationships requires extra effort.
[11003220] |* XML namespaces are problematic to use and namespace support can be difficult to correctly implement in an XML parser.
[11003230] |* XML is commonly depicted as "[[self-documenting]]" but this depiction ignores critical ambiguities.
[11003240] |* The distinction between content and attributes in XML seems unnatural to some and makes designing XML data structures harder.
[11003250] |== Standardization ==
[11003260] |In addition to the [[ISO]] standards mentioned above, other related document include
[11003270] |* ISO/IEC 8825-4:2002 ''Information technology -- ASN.1 encoding rules: XML Encoding Rules (XER)''
[11003280] |* ISO/IEC 8825-5:2004 ''Information technology -- ASN.1 encoding rules: Mapping W3C XML schema definitions into ASN.1''
[11003290] |* ISO/IEC 9075-14:2006 ''Information technology -- Database languages -- SQL -- Part 14: XML-Related Specifications (SQL/XML)''
[11003300] |* ISO 10303-28:2007 ''Industrial automation systems and integration -- Product data representation and exchange -- Part 28: Implementation methods: XML representations of EXPRESS schemas and data, using XML schemas''
[11003310] |* ISO/IEC 13250-3:2007 ''Information technology -- Topic Maps -- Part 3: XML syntax''
[11003320] |* ISO/IEC 13522-5:1997 ''Information technology -- Coding of multimedia and hypermedia information -- Part 5: Support for base-level interactive applications''
[11003330] |* ISO/IEC 13522-8:2001 ''Information technology -- Coding of multimedia and hypermedia information -- Part 8: XML notation for ISO/IEC 13522-5''
[11003340] |* ISO/IEC 18056:2007 ''Information technology -- Telecommunications and information exchange between systems -- XML Protocol for Computer Supported Telecommunications Applications (CSTA) Phase III''
[11003350] |* ISO/IEC 19503:2005 ''Information technology -- XML Metadata Interchange (XMI)''
[11003360] |* ISO/IEC 19776-1:2005 ''Information technology -- Computer graphics, image processing and environmental data representation -- Extensible 3D (X3D) encodings -- Part 1: Extensible Markup Language (XML) encoding
[11003370] |* ISO/IEC 22537:2006 ''Information technology -- ECMAScript for XML (E4X) specification''
[11003380] |* ISO 22643:2003 ''Space data and information transfer systems -- Data entity dictionary specification language (DEDSL) -- XML/DTD Syntax''
[11003390] |* ISO/IEC 23001-1:2006 ''Information technology -- MPEG systems technologies -- Part 1: Binary MPEG format for XML''
[11003400] |* ISO 24531:2007 ''Intelligent transport systems -- System architecture, taxonomy and terminology -- Using XML in ITS standards, data registries and data dictionaries''