Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.22 if

Element type

if

Attributes

cond

Parents

block | catch | error | filled | help | if | noinput | nomatch

Children

assign | audio | clear | disconnect | else | elseif | enumerate | exit | goto | if | log | prompt | reprompt | return | script | submit | throw | value | var

Description

An executable element implementing the if-then-else conditional logic.

DTD

<!ENTITY % if.attrs
  "cond  %expression; #REQUIRED" >

<!ELEMENT if (%executable.content; | elseif | else)* >
<!ATTLIST if
  %if.attrs; >

Language model

03fig22.gif

Attributes

  • cond : expression

    An ECMAScript expression that evaluates to a boolean. If it evaluates to true, the contents within the if element will be executed until an elseif or else element is encountered or the closing </if> tag is encountered.

Children

  • elseif elements

    Marks the beginning of an else-if code block within this if element.

  • else element

    Marks the beginning of the else code block within this if element.

  • executable.content

    Elements and audible nodes that may be executed depending on the evaluation of this if element's cond attribute, the cond attributes of sibling elseif elements, and their position relative to sibling elseif and else elements.

Examples

Example 3-25 A form demonstrating if-else logic

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="1.0">
  <form id="pick">
    <field name="select">
      <grammar>one|two|three</grammar>
      <prompt>Pick a number from one to three.</prompt>
      <filled>
        <if cond="select=='one'">
          <prompt>Your selection was one.</prompt>
          <else/>
          <prompt>Your selection was greater than one.</prompt>
        </if>
      </filled>
    </field>
  </form>
</vxml>
  • + Share This
  • 🔖 Save To Your Account