Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

Attributes of XSL

Added 26 Jul 2008

If you are familiar with HTML, then you are familiar with attributes. These are the commands within the tags that give additional information or instructions to those elements. For example, in XHTML, you can use the tag


without any elements, but if you want to change the line, you use attributes, such as

When you create elements with attributes, you need to declare the possible attributes in your DTD. To do this, you use the tag:
element_name attribute_name type default_value>

For example, my element might have the attribute of "role" with two options "father" or "mother". This would be defined as:

In this example, I've assigned the element with the required attribute of "role". The attribute can be either "father" or "mother".

There are ten types that can be assigned to attributes:

  • CDATA - text
  • enumerated - an exact list of options, like in my example above
  • ID - a unique name for the element
  • IDREF - the value of an ID type attribute
  • IDREFS - multiple IDs, separated by whitespace
  • ENTITY - the name of an entity declared in the DTD
  • ENTITIES - multiple entities, separated by whitespace
  • NMTOKEN - an XML name
  • NMTOKENS - multiple XML names, separated by whitespace
  • NOTATION - the name of a notation declared in the DTD