Saltar la navegación

4.3.- Atributos

Sintaxis:

<!ATTLIST element-name attribute-name attribute-type attribute-value>

DTD ejemplo:

<!ATTLIST payment type CDATA "check">

XML ejemplo:

<payment type="check" />

Donde:

  • attribute-type puede tomar los valores de la tabla 1
  • attribute-value puede tomar los valores de la tabla 2

Tabla 1: valores para attribute-type

Type

Description

CDATA

The value is character data

(en1|en2|..)

The value must be one from an enumerated list

ID

The value is a unique id

IDREF

The value is the id of another element

IDREFS

The value is a list of other ids

NMTOKEN

The value is a valid XML name

NMTOKENS

The value is a list of valid XML names

ENTITY

The value is an entity

ENTITIES

The value is a list of entities

NOTATION

The value is a name of a notation

xml:

The value is a predefined xml value

Tabla 2: valores para attribute-value

Value

Explanation

value

The default value of the attribute

#REQUIRED

The attribute is required

#IMPLIED

The attribute is optional

#FIXED value

The attribute value is fixed

Valor de atributo por defecto:

DTD ejemplo:

<!ELEMENT square EMPTY>
<!ATTLIST square width CDATA "0">

XML ejemplo: El elemento squeare es definido como vacío con un atributo “width” de tipo CDATA y si no se especifica el valor de width, este por defecto será “0”.

<square width="100" />