Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyword vs data metadata in DITA?

Tags:

xml

dita

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?

like image 637
Anders Avatar asked Feb 26 '13 22:02

Anders


2 Answers

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>
like image 155
johntait.org Avatar answered Sep 28 '22 23:09

johntait.org


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:

  • The subject of the property is the element that contains the data element. If the property applies to a topic as a whole, it should go in the topic prolog element or in a topicmeta element in a topicref that points to the topic.
  • The @name attribute on the data element is the primary identifier for processors.
  • The value of the property can be expressed in several different ways:
    • Text value, often expressed using the @value attribute
    • Reference to another resource (topic, image, Web resource, etc.), using the @href attribute
    • Complex structure that is composed of nested data elements
  • You can use an optional title element to provide a label for property.

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?

  • Use the keywords element to specify index terms and keywords that apply to a specific topic, especially when the content of the keywords element should be used in the generated output.
  • Use the data element to embed properties within a DITA topic or DITA map, especially as an aid for custom processing or to harvest properties for automated processing.
  • Use the data element as a basis for specialization.
  • Use the othermeta element to hold name and value pairs for which a semantic element does not exist.
like image 25
Kristen James Eberlein Avatar answered Sep 28 '22 23:09

Kristen James Eberlein