As per a request from last week’s meeting:
Attributes are a way of attaching extra information to XML
elements. Attributes are most important where one must make a principled
distinction between content and metadata. This is especially common in
document-oriented DTDs and schemas where content and metadata tend to have different
properties:
|
Content
|
Metadata
|
Content handling by formatter
|
Shown by default
|
Hidden by default
|
Appropriate DITA base classes
|
Specialized from some body content element.
|
Specialized from an attribute or metadata element.
|
Can influence parent element’s
formatting in CSS
|
Yes
|
No
|
Can have child elements
|
Yes
|
No
|
Can be safely discarded by processes that
do not recognize it
|
Seldom
|
Usually
|
Explicitly defaultable in XML 1.0
|
No
|
Yes
|
Common types of attributes:
- URLs (CDATA)
- Semantically-oriented elements
(e.g. employee records) may have references to other internal systems or
related elements elsewhere
- References to names defined
elsewhere NMTOKENS
- e.g. product names, SKUs,
programming language keywords, etc.
- Filtering attributes (NMTOKENS)
- Title-like attributes (CDATA)
- E.g. HTML’s “alt”
attribute, DITA’s “navtitle” attribute.
- Numeric attributes (NMTOKEN)
- E.g. a picture’s optimal
viewing width and height, the latitude and longitude of a location, the
price of a product.
- Categorization attributes
(NMTOKEN)
- For example, Docbook’s
citebiblioid attribute allows the user to define the type of identifier
that was used: “isbn”, “issn”, “libraryofcongress”
etc.
- In Docbook, an organization
can be “consortium”, “corporate”, “not-for-profit”
or “informal”
- Formatting-oriented attributes
(enumeration or NMTOKEN)
- E.g. align left, align right,
etc.
- Repository identifiers (CDATA)
- Repository may work at more
granular level than file. Then repository identifiers could appear on any
element.
|