CallXML 3.0 Development GuideHome  |  Frameset Home


<throw>  element

The CallXML3.0 <throw> element is a new addition to the markup that allows the developer to programmatically send an event to the application, (and then handle it, via the <on> element), at any point in the application. This is an extraordinarily useful technique for debugging purposes, as well as initiating a 'shunt' operation that send a caller to a different place in the application based on user input and events.


usage
<throw id="(element id)" test="CDATA" value="(variable name)" value-is="STRING" value-is-not="STRING">


attributes
idData Type: (element id)Default: none - attribute is optional
The new 'id' attribute in CallXML3.0 is applicable to all container and action elements. Specifying this attribute allows yet another level of control and event handling when events occur and are caught by the <on> element. When an event occurs, the handler will first check the event, and then verify that the handler has a handler specific to the 'id' attribute to execute. This allows the developer to plan a specific course of action for events based on where in the application that they occur.
testData Type: CDATADefault: Optional
The 'test' attribute is a new supplement to the CallXML markup that permits the developer to execute the contents of a container element, or action element, based on whether or not the specified condition is met. If the defined condition is met, then the code contained within the element is then executed. If the condition is not met, then the application resumes execution with the next sequential container container element in the document.
valueData Type: (variable name)Default: none - attribute is optional
The 'value' attribute specifies the variable name containing the event to be thrown to the application.
value-isData Type: STRINGDefault: none - attribute is optional
Another new attribute, 'value-is', grants the developer with the ability to perform conditional logic upon container elements, or action elements for the first time within the CallXML markup. The value specified in the 'value-is' attribute specifies a string to compare against any 'value' attributes. If the 'value' and 'value-is' equate to 'true', then the element specified will execute. If the value equates to 'false' then the element will be skipped during document execution.
value-is-notData Type: STRINGDefault: none - attribute is optional
Another new attribute, 'value-is-not', grants the developer with the ability to perform conditional logic upon container elements, or action elements, for the first time within the CallXML markup. The value specified in the 'value-is-not' attribute specifies a string to compare against any 'value' attributes. If the 'value' and 'value-is-not' equate to 'false', then the element specified will execute. If the value equates to 'true' then the element will be skipped during document execution.



code samples
<3.0 throw-id>
<?xml version="1.0" encoding="UTF-8"?>

    <callxml version="3.0">

    <do label="R1">

        <prompt value="Lets throw us a user defined bribe event
        for the application to trap and handle"/>

        <wait value="2s"/>

        <throw value="bribe" id="republican"/>
       
        <on event="bribe" target="republican">
        <log>*** REPUBLICAN BRIBE CAUGHT AND ACCEPTED ***</log>
        <prompt value="We just took a bribe from a Republican"/>

        <goto value="#D1"/>
      </on>

    </do>

    <do label="D1">

        <prompt value="Lets take another bribe event, shall we?
        After all, thousands of senators cant be wrong! "/>

        <wait value="2s"/>

        <throw value="bribe" id="democrat"/>
 
        <on event="bribe" target="democrat">
        <log>*** DEMOCRAT BRIBE CAUGHT AND ACCEPTED ***</log>
        <prompt value="We just took a bribe from a Democrat"/>

        <goto value="#R1"/>
      </on>

    </do>

    </callxml>


<3.0 throw-test>
<?xml version="1.0" encoding="UTF-8"?>

<callxml version="3.0">

<do>

  <prompt value="Lets throw us a user defined event
                  for the application to trap and handle"/>
  <wait value="2s"/>


<!-- this event will not get thrown as '6' is not equal to '9'-->
  <throw value="flowers" test="6=9"/>


<!-- this event will get thrown as 'something' -->
<!-- is not equal to 'anything'-->
  <throw value="money"
          test="&apos;something&apos; != &apos;anything&apos; "/>


       
  <on event="money">
    <log>*** MONEY CAUGHT ***</log>
    <prompt value="Just throw money! Throw Money!"/>
  </on>


  <on event="flowers">
    <prompt value="We will never catch flowers.
    Who the heck wants flowers over money, anyhow?
    Except maybe a Democrat"/>
  </on>

</do>

</callxml>


<3.0 throw-value-valueis>
<?xml version="1.0" encoding="UTF-8"?>

  <callxml version="3.0">

    <do value="danny">

        <prompt value="Lets throw us a user defined event
                      for the application to trap and handle"/>
        <wait value="2s"/>

<!-- this event will not get thrown as 'richie' is not equal to 'danny'-->
        <throw value="richie_devito" value-is="richie"/>


<!-- this event will get thrown as 'danny' is equal to 'danny'-->
        <throw value="danny_devito" value-is="danny"/>
       
        <on event="danny_devito">
        <log>*** DEVITO EVENT CAUGHT ***</log>
        <prompt value="We have thrown, and caught
                        a danny devito event"/>
      </on>

    </do>

  </callxml>




additional links
none


  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login



© 2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site