Home > Articles > Web Services > XML

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

This chapter is from the book

3.54 throw

Element type

throw

Attributes

event (2.0) | eventexpr (2.0) | message (2.0) | messageexpr (2.0)

Parents

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

Children

None.

Description

Throws an event, either predefined or application-specific.

DTD

<!ELEMENT throw EMPTY >
<!ATTLIST throw
  event       %event.name;    #IMPLIED
  eventexpr   %expression;    #IMPLIED
  message     CDATA           #IMPLIED
  messageexpr %expression;    #IMPLIED >

Language model

54

Attributes

  • event : event.name

    The name of the event to throw.

  • eventexpr : expression

    An expression that yields the name of the event to throw.

  • message : string

    A string that is a part of the event being thrown.

  • messageexpr : expression

    An expression that yields the message.

Children

None.

Examples

Example 3-65 Throwing user-defined events

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="1.0">
  <form id="showevent">
    <field name="response">
      <grammar>good | bad</grammar>
      <prompt>How are things?</prompt>
      <filled>
        <if cond="response=='bad'">
          <throw event="bad"/>
          <else/>
          <throw event="good"/>
        </if>
      </filled>
    </field>
  </form>

  <catch event="good">
    <prompt>Glad to hear they are good.</prompt>
    <exit/>
  </catch>

  <catch event="bad">
    <prompt>Sorry to hear things are bad.</prompt>
    <throw event="better"/>
  </catch>

  <catch event="better">
    <prompt>Hopefully they will get better.</prompt>
    <exit/>
  </catch>    
</vxml>
  • + Share This
  • 🔖 Save To Your Account