ZVON > References > VoiceXML Reference
Element:else
Parents: | if |
Description:

Go to Standard

Examples:


<vxml version="1.0">
     <form id="getdriverlicense">
          <var name="birthday" expr="'1980-02-10'"/>
          <field name="drivelicense">
               <grammar src="http://grammarlib/drivegrammar.gram" type="application/x-jsgf"/>
               <prompt> Please say your driver’s license number. </prompt>
               <filled>
                    <if cond="validdrivelicense(drivelicense,birthday)">
                         <var name="status" expr="true"/>
                         <else/>
                         <var name="status" expr="false"/>
                    </if>
                    <return namelist="drivelicense status"/>
               </filled>
          </field>
     </form>
</vxml>


<form id="getssn">
     <var name="firstname"/>
     <var name="lastname"/>
     <field name="ssn">
          <grammar src="http://grammarlib/ssn.gram" type="application/x-jsgf"/>
          <prompt> Please say social security number. </prompt>
          <filled>
               <if cond="validssn(firstname,lastname,ssn)">
                    <assign name="status" expr="true"/>
                    <return namelist="status ssn"/>
                    <else/>
                    <assign name="status" expr="false"/>
                    <return namelist="status"/>
               </if>
          </filled>
     </field>
</form>


<if cond="total > 1000">
     <prompt>This is way too much to spend.</prompt>
     <throw event="com.xyzcorp.acct.toomuchspent"/>
</if>
<if cond="amount < 29.95">
     <assign name="x" expr="amount"/>
     <else/>
     <assign name="x" expr="29.95"/>
</if>
<if cond="flavor == 'vanilla'">
     <assign name="flavor_code" expr="'v'"/>
     <elseif cond="flavor == 'chocolate'"/>
     <assign name="flavor_code" expr="'h'"/>
     <elseif cond="flavor == 'strawberry'"/>
     <assign name="flavor_code" expr="'b'"/>
     <else/>
     <assign name="flavor_code" expr="'?'"/>
</if>


<if cond="total > 1000">
     <prompt>This is way too much to spend.</prompt>
     <throw event="com.xyzcorp.acct.toomuchspent"/>
</if>
<if cond="amount < 29.95">
     <assign name="x" expr="amount"/>
     <else/>
     <assign name="x" expr="29.95"/>
</if>
<if cond="flavor == 'vanilla'">
     <assign name="flavor_code" expr="'v'"/>
     <elseif cond="flavor == 'chocolate'"/>
     <assign name="flavor_code" expr="'h'"/>
     <elseif cond="flavor == 'strawberry'"/>
     <assign name="flavor_code" expr="'b'"/>
     <else/>
     <assign name="flavor_code" expr="'?'"/>
</if>


<form>
     <subdialog name="result" src="#getdriverslicense">
          <param name="birthday" expr="'2000-02-10'"/>
          <filled>
               <submit next="http://myservice.example/cgi-bin/process"/>
          </filled>
     </subdialog>
</form>
<form id="getdriverslicense">
     <var name="birthday"/>
     <field name="drivelicense">
          <grammar src="http://grammarlib/drivegrammar.gram" type="application/x-jsgf"/>
          <prompt> Please say your driver's license. </prompt>
          <filled>
               <if cond="validdrivelicense(drivelicense,birthday)">
                    <var name="status" expr="true"/>
                    <else/>
                    <var name="status" expr="false"/>
               </if>
               <return namelist="drivelicense status"/>
          </filled>
     </field>
</form>


<form id="survey_2000_03_30">
     <catch event="exit">
          <goto nextitem="confirm_exit"/>
     </catch>
     <block>
          <prompt> Hello, you have been called at random to answer questions critical to U.S. foreign policy. </prompt>
     </block>
     <field name="q1" type="boolean">
          <prompt>Do you agree with the IMF position on privatizing certain functions of Burkina Faso’s agriculture ministry?</prompt>
     </field>
     <field name="q2" type="boolean">
          <prompt>If this privatization occurs, will its effects be beneficial mainly to Ouagadougou and Bobo-Dioulasso?</prompt>
     </field>
     <field name="q3" type="boolean">
          <prompt>Do you agree that sorghum and millet output might thereby increase by as much as four percent per annum?</prompt>
     </field>
     <block>
          <submit next="register" namelist="q1 q2 q3"/>
     </block>
     <field name="confirm_exit" type="boolean">
          <prompt>You have elected to exit. Are you sure you want to do this, and perhaps adversely affect U.S. foreign policy vis-à-vis sub-Saharan Africa for decades to come?</prompt>
          <filled>
               <if cond="confirm_exit"> Okay, but the U.S. State Department is displeased.
                    <exit/>
                    <else/> Good, let’s pick up where we left off.
                    <clear namelist="confirm_exit"/>
               </if>
          </filled>
     </field>
</form>


<vxml version="1.0">
     <var name="username"/>
     <form id="buysoftware">
          <var name="ccn"/>
          <var name="exp"/>
          <grammar/>
          <initial name="start">
               <prompt> Please tell us the software product you wish to buy and the operating system on which it must run. </prompt>
               <noinput>
                    <assign name="start" expr="true"/>
               </noinput>
          </initial>
          <field name="product">
               <prompt> Which software product would you like to buy? </prompt>
          </field>
          <field mname="operatingsystem">
               <prompt> Which operating system does this software need to run on? </prompt>
          </field>
          <subdialog name="cc_results" src="http://somedomain.example/ccn.vxml">
               <filled>
                    <if cond="cc_results.status=='no_result'"> Sorry, your credit card information could not be Obtained. This order is cancelled.
                         <exit/>
                         <else/>
                         <assign name="ccn" expr="cc_results.creditcardnum"/>
                         <asssign name="exp" expr="cc_results.expirydate"/>
                    </if>
               </filled>
          </subdialog>
          <block> We will now process your order. Please hold.
               <submit namelist="username product operatingsystem ccn exp"/>
          </block>
     </form>
</vxml>