CallXML 3.0 Development Guide Home  |  Frameset Home

  tutorial Hello World  |  TOC  |  tutorial Hello World with Container Inheritance  

Container Element Aliases and Inheritance

The deployment of CallXML 3.0 offers a number of useful enhancements and code shortcuts that were unavailable in previous versions of the markup language. One of the new features the concept of using container aliases, which allows us to define blocks of code with an intelligent nomenclature that 'suits' the code that is executing. The other new feature, specific to container elements, is the concept of 'value inheritance', wich allows us to set a variable value once, at the container level, which will then populate any undefined child element variables that are in an undefined state.


Container Aliases

Those familiar with CallXML 2.0 are familiar with the <block> element as our defacto container element, which logically encloses executable code into easy-to-follow groupings. CallXML3.0 still uses this mantra of defining container elements, but we have added new naming conventions that better label the code to describe what the group of code actually does. All of these aliases are completely identical in form and function, and execute in the same manner:


As mentioned, container aliases allow the developer to customize the naming to more intelligently describe what is happening when the container executes, but we haven't hammered this point home yet. So, let's take a healthy gander at some examples. Let's say a set of code that loops through an array of values, and presents the caller with these values to choose from. In CallXML2.0, we would be stuck using a <block> element, and only a <block> element. If our next container output audio, then moved on to another <block> that performed conditional logic, we would have three plain-vanilla <blocks> that worked, but weren't neccesarily descriptive, nor easy to follow when editing and tweaking:


<block label="looper">
<!-- content here -->
</block>
<block label="audio">
<!-- audio content here -->
</block>
<block label="if_else">
<!-- conditional logic here -->
</block>


Now, let's take a look at how we can use the aliases to make things a bit cleaner:


<hl>do label="looper">
<!-- content here -->
</do>
<hl>with label="audio">
<!-- audio content here -->
</with>
<if label="if_else">
<!-- conditional logic here -->
</block>
</if>


There aren't any requirements to use any particular alias for any operation in CallXML 3.0. Which alias you use is entirely dependent on the coding style and sensibilities of the developer writing the code.


Container Inheritance

The concept of container inheritance is undoubtedly one of the most useful features in 3.0, and can save the devevloper quite a bit of time, if used properly. As we mentioned above, "container inheritance" is the ability to define a variable, or an array of variables, at the container-scope, which can fill in any number of values for child elements that do not have explicit values defined. So we can illustrate the effectiveness of this concept, we will contrast two sets of code:

Without Container Inheritance:

<do label="RGB">
  <playaudio value="you may choose red blue or green.wav"
                  say="you may choose red blue or green"
                  choices="red, blue, green"/>
  <wait value="5s" choices="red, green, blue"/>
  <log value="red blue or green"/>

  <on event="choice:red">
    <playaudio value="you chose.wav"
                  say="you chose"/>
    <say>$session.lastchoice;</say>
  </on>
  <!-- etc -->
</do>


With Container Inheritance:


<do label="RGB" value="you may choose red green or blue.wav" choices="red, green, blue">
  <playaudio/>
  <wait value="5s"/>
  <log/>

  <on event="choice:red">
    <playaudio value="you chose.wav"
                  say="you chose"/>
    <say>$session.lastchoice;</say>
  </on>
  <!-- etc -->
</do>


You'll note that in our second example, we didn't define any value for the <playaudio>, nor any 'choices' for the <wait> or any output for the <log> elements, because we didn't need to: As these are unspecified, the container element will fill in the blanks for us, and save us quite a bit of time when coding our real-world application.

Now that we have covered the high-level overview of container alaises and inhertitance, let's now put this knowledge to good use by moving on to our tutorial, where we can get our hands dirty, and write some code of our own!






  ANNOTATIONS: EXISTING POSTS
lavanyasubbu
6/20/2010 3:57 PM (EDT)
Spelling mistake
"wich allows us to set a variable value once"
VoxeoBrian
6/20/2010 4:06 PM (EDT)
Hello,

Thanks for the catch, I will make sure our document keepers are aware.  We will close this ticket out at this time.

Regards,

Brian F.
revmobile
11/30/2010 1:03 PM (EST)
Below:
    Now, let's take a look at how we can use the aliases to make
    things a bit cleaner:

You have an unneeded </block> before the closing </if>

login
  tutorial Hello World  |  TOC  |  tutorial Hello World with Container Inheritance  

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