0.33.1: XML constructs

This topic outlines the components of an XML implementation.

Document Type Definition (DTD)

The XML recommendation does not specify a set of tags that can appear in an XML document. Instead, XML implementers determine the actual tags that will be permitted in their documents. Those tags are defined formally in an XML-based grammar, such as a DTD. A DTD can be within the XML document or in a separate file that is referenced in the document's <!DOCTYPE> statement.

DTDs are optional but are almost essential in cases when XML documents must be exchanged among a large number of users. A DTD can be placed inline within the XML document or in an external file.

Well-formed versus valid XML documents

The structure of an XML document is governed by syntax rules for its tag set. There are general rules that are applied to all XML documents to determine whether the document is well-formed. To be parsed, an XML document must be well-formed. The XML 1.0 Recommendation describes the rules for well-formed documents, some of which are:

An XML document that is well-formed and conforms to the rules specified in its grammar is a valid XML document. XML document validating processors (validators) must report validation errors, but they are not required to end the processing.

Stylesheets

XML documents can be exchanged among enabled applications without human intervention. In such cases, XML implementers do not need to be concerned about document presentation. In contrast, if users need to display a formatted XML document, implementers must determine the presentation format.

XSL stylesheets control how XML documents are presented. Stylesheets control whether all or parts of the document are displayed, as well as aspects of the appearance, such as fonts, color, and alignment.

XML also supports Cascading Style Sheet (CSS) language, which was developed for use with HTML. CSS is ideal for controlling actual rendering in the browser, while XSL is designed for more complex document subsetting and formatting. XSL supports advanced features, such as including JavaScript in style sheets, controlling formatting of tag content, and hiding content.