O'Reilly logo

XML Companion, The, Third Edition by Neil Bradley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Attributes

Attributes are created and referenced in essentially the same way as elements. The Attribute element is used to create an attribute, and the name of the attribute is provided by the Name attribute. The Type attribute can be used, just as in element definitions, to specify the type of value it can contain. This declaration can appear at the end of a complex type definition. In the following example, the Security attribute is added to the Chapter element:

<element name="chapter">
  <complexType>
    ...
    <attribute name="security" type="string" />
  </complexType>
</element>

<!-- DTD EQUIVALENT:
     <!ATTLIST chapter security CDATA #IMPLIED> -->

Attribute Type values must always be simple data types, such as the 'string' type, and never complex ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required