Home > Articles > Web Services > XML

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

This chapter is from the book

3.5 catch

Element type



event | cond | count


field | form | initial | menu | object | record | subdialog | transfer | vxml


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


Catches the events listed in the event attribute. The count and cond attributes optionally control if a catch is visited.

Anonymous variables:

_event (2.0)

Is the event that was thrown.


Is the corresponding message string of the throw element (see 3.54, “throw,”).


<!ELEMENT catch (%executable.content;)* >
<!ATTLIST catch
  event %event.names; #REQUIRED    
  %event.handler.attrs; >

Language model



accept : (exact | approximate)

New to VoiceXML 2.0, this attribute can be set to exact (by default) or approximate. It specifies how the grammar recognition should handle each choice element. Individual choice elements can override this setting.

cond : expression = true

This event handler will only be executed if this ECMAScript expression evaluates to true.

count : integer

The event handler should be run only when the counter associated with a menu, form, or form item is equal to the quantity specified by this attribute. In the case where there is no count value equal to the counter, then the catch with the lowest count value, which is greater than the counter, will be selected. When the counter is greater than all count values, the catch with the highest count value will be selected.

event : event.names

One or more events that this catch block handles.



The code to be executed when this catch block handles an asynchronous event (e.g. the caller hanging up the phone, uttering a word recognized by an active grammar, etc.).


Example 3-7 Catching the same event with changing responses

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="1.0"> 
  <form id="flavor">
    <field name="selection">
      <grammar> flavors </grammar> 
        Please say one of the following flavors: chocolate, vanilla, 
        or strawberry. 

      <catch event="nomatch noinput" count="1"> 
        Select from chocolate, vanilla, or strawberry. 
      <catch event="nomatch noinput" count="2">
        You must say either chocolate, vanilla, or strawberry. 
      Your selection is being prepared.
  • + Share This
  • 🔖 Save To Your Account