There are two "generic" types of metadata tags in DITA, the data element and the keyword element. Of course there's also the othermeta, but apparently that's supposed to be deprecated soon, and the name suggests its sort of a last resort anyhow.
So the keyword seems to closely resemble tags in web applications, i.e. what is commonly used for "folksonomies". But what is the exact difference between data and keyword, and when should you use which?
The <data>
element is primarily for specialization so it's probably not wise to use it directly. The <keyword>
element is better.
This:
<metadata> <keywords> <keyword>red</keyword> <keyword>green</keyword> <keyword>blue</keyword> </keywords> </metadata>
will render to this in the DITA-OT XHTML transform:
<head> <meta name="DC.subject" content="red, green, blue"/> <meta name="keywords" content="red, green, blue"/> </head>
If you want to add tags, I'd consider using subject scheme maps, which will allow you to include a list of controlled values.
If you specialize the @base
or @props
attribute, you can add metadata with much more control. Here, we have a @props
attribute specialized to @era
.
You can then add the @era
attribute to an element in a topic, or to the <topicref>
element in a map.
<subjectdef keys="era_attributedef">
<topicmeta>
<navtitle>Era of production by decade and producer</navtitle>
</topicmeta>
<subjectdef keys="producer">
<hasInstance>
<subjectdef keys="sixties">
<subjectdef keys="verity_lambert"/>
<subjectdef keys="john_wiles"/>
<subjectdef keys="innes_lloyd"/>
<subjectdef keys="peter_bryant"/>
<subjectdef keys="derrick_sherwin"/>
</subjectdef>
<subjectdef keys="seventies">
<subjectdef keys="barry_letts"/>
<subjectdef keys="philip_hinchcliff"/>
<subjectdef keys="graham_williams"/>
</subjectdef>
<subjectdef keys="eighties">
<subjectdef keys="john_nathan-turner"/>
</subjectdef>
</hasInstance>
</subjectdef>
<enumerationdef>
<attributedef name="era"/>
<subjectdef keyref="era_attributedef"/>
</enumerationdef>
You are a little off-track here; the keyword element is NOT a metadata element. The keyword element is a generic text element, often used for product names. I think the element that you probably wanted to specify here was the keywords element. Also, you really don't want to write off the othermeta element; it is not deprecated and quite useful.
keywords element
The keywords element can be used either at the topic or map level. It holds a list of terms from a subject vocabulary, tagged with either the keyword or indexterm elements. The keyword and indexterm elements are considered metadata elements, and they should be reflected in output as appropriate for the medium. The indexterm elements commonly generate indices; in XHTML output, the keyword elements generally are added to the XHTML and used for search-engine optimization. (This is standard functionality of the DITA-OT, although the free PDF rendering engine that ships with the DITA-OT does not generate an index.)
data element
Used as-is, the data element represents a property within a DITA topic or map. The following are the key aspects:
By default, processors ignore the content of data elements. However, custom processing can be built that uses the content of specific data elements for formatting and so forth.
Used as a basis for specialization, the data element is especially useful. It enables more precise semantics, as well as enumerations of controlled lists of attributes for specific elements. You can see many examples of its use as a specialization base if you examine the metadata elements used in the bookmap and learning & training specializations.
See the data element topic in the DITA 1.2 specification for some concrete examples.
othermeta element
The othermeta element is designed to hold content for which no existing metadata element seems to apply. It essentially holds a name and value pair. You use the @name attribute to name the property and the @content attribute to hold the value.
When should you use which particular element?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With