Excluding topics: conditional processing at topic level

If a whole topic is to be excluded from the output in a conditional processing scenario (that is, the condition applies to a whole topic), the metadata attribute must be defined in the topic reference in the ditamap.

If you want to exclude a topic in a collection from the output, you have a number of options. These include:

  • Not including the topic in the ditamap, and processing a different ditamap when the topic is required.
  • Setting a condition attribute in the topic so that the topic can be filtered during the build process.
  • Setting a condition attribute in the topicref in the ditamap.

The best option is to construct different ditamap files for different publication outputs, rather than try to use the same ditamap with many condition attributes. The effort required to set up and maintain the condition attributes is a lot higher than working with different maps, particularly when the technique of using nested maps is used.

If having separate ditamaps is not practical, the best approach is to filter at the ditamap level (that is, apply the condition attribute value in the topicref element). If the topic is also referenced in the reltable section of the map, you must also apply the condition attribute to those topicref elements.

If a topic is to be excluded from an output based on conditions, logic suggests that the filtering condition attribute should be applied to the topic root element, and not to the topicref element (as recommended). For example, if the topic is intended for administrators only, then the condition metadata should be stored in the topic. However, excluding the entire content of a topic would leave an empty XML file; that is, an XML file without a root element. Such a file would be invalid, as an XML file must have a root element! The processing would then have to stop.

Applying a filtering attribute to the topicref element in the ditamap will only exclude the topic from the output if there is only the one reference to that topic. You should take care if applying conditions in the topic that you apply the conditions to all references to the topic, and that you do not leave dangling topicrefs.