Wednesday, July 15, 2015

Controlled Attribute Values for your DITA Project

Share to Facebook Share to Twitter Email This Share on Google Plus Share on Tumblr

Frequently when editing DITA content you will feel the need to enforce a controlled set of values when editing certain attributes. For example you may want to impose that the values for the @outputclass attribute on the element codeblock are either language-xml or language-css. This is useful in order to remind writers that any other value will not be interpreted by the build process in a significant manner.

Oxygen has a couple of easy ways in which controlled values can be imposed for certain attributes:
  1. You can edit the XML configuration file OXYGEN_INSTALL_DIR/frameworks/dita/resources/cc_value_config.xml and provide additional entries. In the case of our small example for providing controlled values for the @attribute the configuration file should contain an additional entry:
    <match elementName="codeblock" attributeName="outputclass">
     <items action="addIfEmpty">
      <item value="language-xml" annotation="XML Syntax Highlight"/>
      <item value="language-css" annotation="CSS Syntax Highlight"/>
    Besides providing a hard-coded list of values the content completion configuration file is flexible enough to allow calling an XSLT stylesheet which could retrieve those values from other sources (for example via HTTP from an Exist database).
  2. Provide those controlled values via a Subject Scheme Map (my favorite). Coming back to our example, you can create a small Subject Scheme map with the file name controlledValues.ditamap and the content:
    <!DOCTYPE subjectScheme PUBLIC "-//OASIS//DTD DITA Subject Scheme Map//EN""map.dtd"> 
                <navtitle>Provide controlled attributes</navtitle>
            <subjectdef keys="languageTypeKey">
                <subjectdef keys="language-xml">
                        <navtitle>XML Syntax Highlight</navtitle>
                <subjectdef keys="language-css">
                        <navtitle>CSS Syntax Highlight</navtitle>
            <elementdef name="codeblock"/>
            <attributedef name="outputclass"/>
            <subjectdef keyref="languageTypeKey"/>
    then you can refer to it from your main DITA Map like:
    <topicref href="controlledValues.ditamap" format="ditamap" type="subjectScheme"/>
  3. If the attributes on which you want to impose certain values are DITA profiling attributes, you can go to the Oxygen Preferences->Editor / Edit modes / Author / Profiling/Conditional Text page and define the set of allowed values for them.

The only problem with the first approach is the fact that validation will not impose those values and writers will not receive validation error messages if they set another value for the specific attribute. So you will probably need to add a Schematron check in order to signal errors when a certain attribute's value does not match the list of controlled attribute values. For both the second and third approaches, validation will warn the writers if certain attribute values do not match values in the controller values list.


  1. Hi Radu,

    Many thanks for this write-up. An additional option is to use oXygen Author CSS extensions, for example:

    *[class~="topic/prodinfo"]:after {
    edit, "@content",
    editable, true,
    values, "application_note, architecture_specification, data_sheet, addendum, evaluation_document, short_data_sheet, requirement_specification, user_manual, white_paper"
    columns, 20);


  2. Hi Frank,

    Right, allowing writers to edit the attributes directly in the Author editing mode with a custom CSS is also a good strategy. So thanks for adding this.

    My colleague Alex will probably also post about a more complex situation in which you have an element with two attributes, the values for the second attribute need to be computed based on the values for the first attribute.

    For example if you have a the list of possible @value choices would depend on the value set in the data @name attribute.


  3. Part (2) of this article can be found at:

  4. Hi, can I somehow integrate a value list which is not defined in as subjectScheme but as a VDEX list (is XML)?

  5. You should check out part (2) of this article:
    which allows you to call an XSLT to provide controlled values.