9.6.3 Reusing the same topics with different conditions

Suppose you want to use the same map in two places in your output, with different conditions applied. If (for example) you insert the following branch PI marker in a map:

<?dtall branch="productA" ditaval="producta.ditaval" ?>

then all topics referenced in branch productA, and no others, acquire the conditions specified in producta.ditaval. But you can also insert:

<?dtall branch="productB" ditaval="productb.ditaval" ?>

in the same map, with the very same files in scope, and with two <topicref> elements get the two outputs in one document. In each case, you would insert the branch PI marker just before the <topicref> you want it to influence.

For example, you might set up a map like this:

<map>
  <topicref href="common_intro.dita" />
  <topichead navtitle="Product A">
    <?dtall branch="productA" ditaval="producta.ditaval" ?>
    <topicref href="product.ditamap" format="ditamap" />
  </topichead>
  <topichead navtitle="Product B">
    <?dtall branch="productB" ditaval="productb.ditaval" ?>
    <topicref href="product.ditamap" format="ditamap" />
  </topichead>
</map>

The very same map is used for both branches. So you get two copies, each filtered by its own ditaval. You have complete flexibility to reuse a topic any number of times in the same project, with different conditions for each use. You can apply a different ditaval to each branch, or the same ditaval to disjoint areas of the map.

This method of accommodating duplicated topics avoids the workaround of reverse conref elements, which is the usual (and ugly) answer: create empty topics for each place of use, and conref the real information from a library of topics, as opposed to just referencing the topic you want to use in the map.

Previous Topic:  9.6.2 Designating map sections as named branches

Next Topic:  9.6.4 Directing a cross reference to the correct branch

Parent Topic:  9.6 Scoping and filtering within maps

Sibling Topics:

9.6.1 Understanding the advantages of filtering in maps

9.6.2 Designating map sections as named branches

9.6.4 Directing a cross reference to the correct branch

9.6.5 Directing a content reference to the correct branch

9.6.6 Limiting the scope of keydefs by branch

9.6.7 Directing a key reference to the correct branch