Wednesday, February 11, 2009

Get The Boot - Macy's

DTD Tutorial


document types and their layout mode (old but still useful)

DTDs...

A DTD is primarily used for the expression of a schema via a set of declarations that conform to a particular markup syntax and that describe a class, or type, of document, in terms of constraints on the structure of that document. A DTD may also declare constructs that are not always required to establish document structure, but that may affect the interpretation of some documents. XML documents are described using a subset of DTD which imposes a number of restrictions on the document's structure, as required per the XML standard (XML is in itself an application of SGML optimized for automated parsing). DTDs are written in a formal syntax that explains precisely which elements and entities may appear where in the document and what the elements’ contents and attributes are. DTD is native to the SGML and XML specifications, and since its introduction other specification languages such as XML Schema and RELAX NG have been released with additional functionality.

As an expression of a schema, a DTD specifies, in effect, the syntax of an "application" of SGML or XML, such as the derivative language HTML or XHTML. This syntax is usually a less general form of the syntax of SGML or XML.

In a DTD, the structure of a class of documents is described via element and attribute-list declarations. Element declarations name the allowable set of elements within the document, and specify whether and how declared elements and runs of character data may be contained within each element. Attribute-list declarations name the allowable set of attributes for each declared element, including the type of each attribute value, if not an explicit set of valid value(s).

The declaration establishes that the document is an instance of the type defined by the referenced DTD.

The declarations in a DTD are divided into an internal subset and an external subset. The declarations in the internal subset are embedded in the Document Type Declaration in the document itself. The declarations in the external subset are located in a separate text file. The external subset may be referenced via a public identifier and/or a system identifier. Programs for reading documents may not be required to read the external subset.

n a DTD markup declarations are used to declare which elements types, attribute lists, entities and notations are allowed in the structure of the corresponding class of XML documents.[1]

[edit] Element Type Declarations

An Element Type Declaration defines an element and its possible content. A valid XML document only contains elements that are defined in the DTD.

An element’s content is specified by some key words and characters:

* EMPTY for no content
* ANY for any content
* , for orders
* | for alternatives ("either...or")
* ( ) for groups
* star for any number (zero or more)
* + for at least once (one or more)
* ? mark for optional (zero or one)
* If there is no *, + or ?, the element must occur exactly one time

Attribute List Declarations

An Attribute List specifies the name, data type and default value of each attribute associated with a given element type[2], for example:

id ID #IMPLIED
src CDATA #REQUIRED
>
There are the following attribute types:

* CDATA (It stands for a character set of data.)
* ID
* IDREF and IDREFS
* NMTOKEN and NMTOKENS
* ENTITY and ENTITIES
* NOTATION and NOTATIONS
* Listings and NOTATION-listings

A default value can be used to define whether an attribute must occur (#REQUIRED) or not (#IMPLIED), whether it has a fixed value (#FIXED) and which value should be used as a default value ("…") in case the given attribute is left out in a XML tag.

No comments:

Post a Comment