| CallXML 3.0 Development Guide | Home | Frameset Home |
|
<block><case><do><if><loop><switch><with><while>choicescleardigitsforeachlabelnextrepeattestvalue-isvalue-is-notvar
<block label="B1" value-is="foo">
..
</block>
<case label="B1" value-is="foo">
..
</case>
<with label="B1" value-is="foo">
..
</with>
<block> elements in a slightly different way:
<block choices="red, green, blue">
<say>you can choose red, green, or blue</say>
</block>
<block foreach="first, second, third" var="i">
<say> this is the $i; time i'll say something</say>
</block>
<block test="1=1">
<say>one does equal one</say>
</block>
<block> elements are doing when scrolling through a document that contains a large amount of these ambiguous container elements. Although, it is much easier to read and intuit the code at a glance by writing the code as we have in our second example:
<with choices="red, green, blue">
<say>you can choose red, green, or blue</say>
</with>
<block foreach="first, second, third" var="i">
<say> this is the $i; time i'll say something</say>
</block>
<if test="1=1">
<say>one does equal one</say>
</if>
<block> to a <loop> does not imply that we can perform complex JavaScript operations within the element, nor does it imply that CallXMl scoping , or nesting rules no longer apply. Down deep in the Application Gateway Software, <loop> equals <foreach><block> equals <block> in all ways, shapes, and forms.
<callxml version="3.0">
<do value="foo.wav" choices="bar">
<say />
<wait value="5s"/>
<log />
<playaudio />
<on event=" choice=bar">
<log> !!!!! bar event is caught !!!!! </log>
</on>
</do>
</callxml>
<playaudio>, <say>, or <log> elements, but at runtime, the CallXML will execute as follows:
<callxml version="3.0">
<do value="foo.wav" choices="bar">
<say choices="bar"/>
<wait value="5s" choices="bar"/>
<log value="foo.wav"/>
<playaudio value="foo.wav"/>
<on event="choice=bar">
<log> !!!!! bar event is caught !!!!! </log>
</on>
</do>
</callxml>
<say>, <log>, and <playaudio> elements. The same is true for the container-level 'choices' attribute tacking on its values to the <wait> and <say> elements. Obviously, this is a very simple example illustrating the conceptual uses of container inheritance, but with a little creativity, one can see the myriad possibilities that exist for this new feature.<playaudio> element within the CallXML application. For simplicity's sake, these values will be sequential numeric values that will indicate a countdown:
<callxml version="3.0">
<with foreach="10.wav, 9.wav, 8.wav, 7.wav, 6.wav, 5.wav, 4.wav, 3.wav, 2.wav, 1.wav" var="countdown">
<playaudio value="$countdown;"/>
<log value="$countdown;"/>
<wait value="1s"/>
</with>
<do>
<say>
liftoff!
</say>
</do>
</callxml>
<playaudio> tag defined for every audio file we meant to output, as well as having to code our array looping on the backend, (as opposed to doing it within the CallXML context).
<playaudio>
<getdigits>
<on event=choice:1">
<hl>PlayAudio>
<getDigits>
<on event Choice="1">
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<block label="B0" next="#D2">
<log value="**** ENTERING B0 ****"/>
<do label="D1" next="#D2">
<log value="**** ENTERING D1 ****"/>
</do>
<do label="D2" next="#D4">
<log value="**** ENTERING D2 ****"/>
</do>
<do label="D3">
<log value="**** ENTERING D3 ****"/>
</do>
</block>
<do label="D4" next="#D3">
<!-- This 'next' target of '#D3' will never be executed, -->
<!-- as it sits outside of the nested block scope -->
<log value="**** ENTERING D4 ****"/>
</do>
<goto next> in place of the 'next' container element attribute will not function for navigation between nested containers. Therefore, it is recommended that you not use the <goto> element within your code unless transitioning to an entirely separate page, or submitting variables is required by your application.<goto> or <do next> target of 'MyDoc.xml#B3' would throw an 'event: error "document" (invalid target for goto or next attribute)' message to the Voxeo Logger.
<callxml version="3.0">
<do>
<say>please leave your message.</say>
<recordaudio value="mailto:bob@home.com" maxsilence="4s" maxtime="45s"/>
<on event="maxsilence">
<log>*** MAXSILENCE EVENT OCCURRED ***</log>
</on>
<on event="maxtime">
<log>*** MAXSILENCE EVENT OCCURRED ***</log>
</on>
<prompt value="thank you">
</do>
<do>
<playaudio value="holdmusic.wav"/>
</do>
</callxml>
<onanswer> or <reject> elements, note that best practices dictate that you immediately transition to a new starting block, else we run the risk of other handler events not getting properly executed. Nesting the contents of your entire CallXML document within an <on event="answer"> element is also inadvisable for the very same reason. For example, the following code sample shows that neither the <block> nor the <say> element will ever be executed:
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<on event="answer">
<do label="D1" repeat="3">
<say choices="*"> press the star key now </say>
<on event="choice:*">
<log value="*** USER PRESSED STAR ***"/>
</on>
</do>
</on>
</callxml>
<?xml version="1.0" encoding="UTF-8"?>
<callxml version="3.0">
<on event="answer">
<goto value="#D1"/>
</on>
<do label="D1" repeat="3">
<say choices="*"> press the star key now </say>
<on event="choice:*">
<log value="*** USER PRESSED STAR ***"/>
</on>
</do>
</callxml>
| ANNOTATIONS: EXISTING POSTS |
| login |
|