VoiceXML 2.1 Development GuideHome  |  Frameset Home


<elseif>  element

The elseif element is used to specify additional content when all other else or if  statements equate to ‘false’.  When a series of if-elseif-else statements are encountered, the application will execute the first one which evaluates to ‘true’.


usage
<elseif cond="CDATA">


attributes
condData Type: CDATADefault: Required
The cond attribute specifies any valid expression, which equates to the value to be evaluated.



shadow variables
none


parents
<if>


children
none


code samples
<If-Else-ElseIf> sample
<?xml version="1.0" encoding="UTF-8"?>

<vxml version = "2.1">

<meta name="author" content="Matthew Henry"/>
<meta name="copyright" content="2005 voxeo corporation"/>
<meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/>

<form id="F1">
  <field name="F_1">
    <prompt> who would win in a fist fight, Oprah, Madonna, or James Brown? </prompt>
    <grammar type="text/gsl">[ oprah madonna (james brown) ] </grammar>

    <filled>
      <if cond="F_1=='oprah'">
        <prompt>
          you really think Oprah could duke it out
          with the Godfather of soul?
        </prompt>

      <elseif cond="F_1=='madonna'"/>
        <prompt>
          madonna would get creamed, who do
          you think you are kidding?
        </prompt>

      <else/>
        <prompt>
          James Brown would whip up on both
          Oprah and Madonna
        </prompt>

      </if>
    </filled>
</field>

</form>
</vxml>



additional links
W3C 2.0 Specification


  ANNOTATIONS: EXISTING POSTS
Deke
8/19/2005 4:27 PM (EDT)
Hey, I just noticed the usage is wrong on this one. :)
MattHenry
8/19/2005 4:37 PM (EDT)
Hiya Deke,


I'm not sure that I grok what it is that you are saying, as the code example looks valid to me...can you expand on your statement please?

Thanks!

~Matt

Deke
8/19/2005 5:26 PM (EDT)
Sure. :)

This is actually brian@inntec by the way, so don't hold Deke accountable for my half-fried ramblings.

Using some home-brew code generation techniques, I've auto-generated some neat tools (dozens and dozens of .net classes) by basically screen scraping your help documents. My tools rely on the usage (and by that I mean the slot at the top of your help documents where it says: usage) being correct, so any time one's wrong it's apparent.

This is the first one I've run into that gave me any trouble, so I thought I'd let you know.

The usage for this one is defined as: <elseIf />

But it should be something like <elseif cond="CDATA" />

And to be consitant with the rest of your docs, the cond would normally be defied.

The capitalization problem is apparently very important! In my code that used elseIf instead of elseif, the staging platform didn't throw an error and instead executed all the code as if there weren't any <else> blocks at all.

There are other places in your documentation that use elseIf instead of elseif, too. The children declarations for <if>, for starters -- my code wouldn't let me add an elseif to if, because elseif isn't a valid child ( elseIf is of course).

I realize I must sound like I have autism at the moment with this huge speil. I've been at this for awhile today. :) 
MattHenry
8/19/2005 5:47 PM (EDT)
Hiya Brian,

I see your point; i have changed this element name in our most recent doc build, which should be live sometime in the next week or so.

Thanks!

~Matt
mtatum111
9/10/2008 10:37 PM (EDT)
shouldn't cond be an attribute of <elseif>

Thanks for any explanation.
voxeoJeffK
9/11/2008 12:37 AM (EDT)
Hi,

Yes, "cond" is an attribute of <elseif>. Thank you for bringing notice to this oversight in our documentation. The documentation fix will take effect in a few days.

Regards,
Jeff K.

login



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