Skip to content

if

Branches on the result of one condition expression. The element can be used recursively to express multi-step decisions.

<if>
  <has_shared_value predicate="sourdough_status"/>
  <then><jumpto type="perform" action="freshen_up_sourdough"/></then>
  <else><jumpto type="perform" action="start_sourdough"/></else>
</if>

Children and placement

The first child is exactly one condition expression. It may be a proposition, a value/store condition, an iterator/query availability test, or a Boolean composition. Optional then and else children each contain a plan. Either branch can contain plan items, including nested if items; an absent branch does nothing. The if itself can occur in a plan, postplan, or conditional branch.

Examples

Jump to a different perform goal depending on whether the DDD already has a shared value:

<if>
  <has_shared_value predicate="sourdough_status"/>
  <then><jumpto type="perform" action="freshen_up_sourdough"/></then>
  <else><jumpto type="perform" action="start_sourdough"/></else>
</if>

Assume a value only when the selected ingredient is water:

<if>
  <in_shared_commitments predicate="selected_ingredient" value="water_ingredient"/>
  <then>
    <assume_system_belief>
      <proposition predicate="quantity" value="200 g"/>
    </assume_system_belief>
  </then>
</if>

See Conditions for supported tests and their JSON form.