Monday, August 24, 2015

DITA 1.3 Key Scopes - Next Generation of Reuse

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

Thanks to the hard working OASIS DITA TC Group the DITA 1.3 standard is quite close to being released. Oxygen 17.1 which will be released probably in September this year will have experimental DITA 1.3 support. This will include publishing using a custom build of the latest DITA Open Toolkit 2.x engine in which the main developer Jarno Elovirta has already added incipient support for key scopes and branch filtering.

In this blog post I'm going to give you a small example of how key scopes can benefit simple cases of reuse which could not be done previously.

Let's say you have a simple DITA task in which you have described how a certain task can be performed for a certain product. In our case, the task describes peeling a potato:

The task works and at some point in your Vegetables Soup publication you realise you need to write a similar task about peeling cucumbers. The task is exactly the same, except the product name. So naturally you want to reuse the existing written task. For this we re-write the task so that instead of of the product potatoes it contains a key reference:
<ph keyref="vegetable"/>
Next we need to define in our DITA Map the vegetable key and bind it to a specific value in the potatoes context:
 <topicref href="potatoes_overview.dita" keyscope="potatoes">
  <!-- Define the vegetable key value in this key scope -->
  <keydef keys="vegetable">
   <topicmeta>
    <keywords>
     <keyword>potatoes</keyword>
    </keywords>
   </topicmeta>
  </keydef>
  <!-- Reference to the common task -->
  <topicref href="peeling.dita"/>
 </topicref>
and add in our DITA Map another key scope with the overview and the task which deal with cucumbers peeling:
 <topicref href="cucumbers_overview.dita" keyscope="cucumbers">
  <!-- Define the vegetable key value in this key scope -->
  <keydef keys="vegetable">
   <topicmeta>
    <keywords>
     <keyword>cucumbers</keyword>
    </keywords>
   </topicmeta>
  </keydef>
  <!-- Reference to the common task -->
  <topicref href="peeling.dita"/>
 </topicref>
As you may have noticed, we have not used the key scope names for anything. Just by defining the key scopes, we made the product name to be expanded differently in both contexts. But our Vegetables Soup publication may also contain a topic which lists all possible vegetables. This topic is defined in a context outside any key scope:
<topicref href="vegetables_over.dita"/>
and this overview topic can refer to each product name using the full keyscope key reference value:
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="vegetables_over">
  <title>Vegetables Overview</title>
  <body>
    <p>This is an overview of all vegetables necessary to make soup. You will learn how to use
      vegetables like <ph keyref="potatoes.vegetable"/> and <ph keyref="cucumbers.vegetable"/> to
      make a great starter soup.</p>
  </body>
</topic>

As stated before, this kind of reuse was not possible using the standard DITA 1.2 standard constructs. As it turns out, with DITA 1.3 we can also implement this kind of reuse using branch filtering. The DITA samples for this post can be downloaded from http://www.oxygenxml.com/forum/files/keyscopesBlogSamples.zip.

As usual any feedback is welcomed.

If you would like to beta test Oxygen XML Editor 17.1 with experimental DITA 1.3 support please contact us to support@oxygenxml.com.

1 comment:

  1. Video showing Key Scopes and Branch Filtering as implemented in Oxygen 17.1 and newer:

    https://www.oxygenxml.com/demo/DITA_13.html

    ReplyDelete