• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Learning DITA

Free DITA training

Free DITA training

  • Log in
  • Register
  • Newsletter
  • Profile
  • Privacy
  • Home
  • About
  • Courses
  • News
  • Resources
  • Support the site
  • Contact
  • Recordings

Marking conditional elements

Posted on 12.02.16

Advanced reuse in DITA Lesson 1: Using conditions Marking conditional elements
Lesson Progress
0% Complete

DITA conditional filtering allows you to choose what to show and hide in your DITA topics when they are processed for output.

You mark DITA elements for filtering by adding special conditional attributes to elements; the value you use with a conditional attribute is used to determine whether the element should be hidden (filtered out) or shown.

The four basic conditional attributes and their suggested uses are:

audience
Content is intended for a specific group of readers. The audience can be seen a number of different ways; it might be the experience level, role, security clearance, or some other way of grouping potential readers.
platform
Content is specific to a particular hardware or software platform.
product
Content is specific to a particular product.
otherprops
Content is specific to a custom aspect.

For example, you might use the platform attribute to indicate whether content is intended for iPhone or Android users:

<p platform="android">Visit Google Play for more information.</p> 
<p platform="iphone">Visit the App Store for more information.</p>

When generating output for Android users, you can tell the DITA filtering mechanism to hide elements where platform=”iphone” and show elements where platform=”android”. To generate output for iPhone users, you show elements where platform has the value “iphone” and hide elements where platform has the value “android”. (How to hide and show content is described later in this lesson.)

The names of the attributes are defined in the DITA specification. They are a suggestion about how you might use them, but you should not feel locked into using them specifically for audience, platform, or product filtering; it’s up to you to determine how you want to use each one.

As with the attributes themselves, the values you use with each of the conditional attributes are up to you to decide. You can use any characters you want for the conditional attribute values, except for the space character. Case is important in the conditional attribute values, so choose one form of capitalization and use it consistently.

You can specify multiple values in these attributes; separate each value with one or more spaces.

The single most important thing, however, is that all content creators in your group, team, company, or organization agree on the purpose of each of the attributes and the values to use with the attributes.

Note: The four attributes listed here are just a starting point. It is possible to use DITA specialization to create additional conditional attributes that have meaning for your content. The DITA specification identifies another conditional attribute: props. This attribute is used as the basis for specialization.

Keep in mind that filtering of elements extends to DITA map elements, such as <topicref> and <mapref>. This way, you can use conditional attributes and filtering to remove entire topics or chapters from your output.

Contributors
  • Simon Bate
  • Jake Campbell
  • Gretyl Kinsey
Previous Topic
Back to Lesson
Next Topic

sidebar

Blog Sidebar

  • Scriptorium logo
    Maximize the value of your content. Read more.
  • Scriptorium logo
    Need DITA help? We offer flat-rate consulting. Get help.
  • Scriptorium logo
    Already in DITA and need support? Contact us.
RSSTwitter

Want to add content? Join the ditatraining GitHub repository.

  • Home
  • Sponsor
  • News
  • Contact
  • Privacy

Maintained by Scriptorium Publishing

Logo and site presentation © 2015-2021 Scriptorium Publishing. Content based on the open-source DITA training project.