| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<form> level will be given dialog scope, while variables declared at the <vxml> level will be given document scope. Variables declared at the <vxml> level within the application root document will inherit application scope.<form> of a document will not be available within the second <form>, unless it is passed along via a <submit>, or if it is explicitly assigned a higher scope while within the <form>.<block> or within a <field>. They will only be considered active when the application visits and executes these form items.
<value expr="application.MyVar"/>
<value expr="document.MyVar"/>
<value expr="dialog.MyVar"/>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0">
<meta name="maintianer" content="yourEmail@here.com"/>
<var name="DocumentVar" expr="'document'"/>
<!-- IT IS IMPORTANT TO REMEMBER *NOT* TO ASSIGN ANY VARIABLES
WITH AN 'application' PREFIX WITHIN THE ROOT DOCUMENT ITSELF,
ELSE AN ERROR.SEMANTIC WILL BE THROWN:
<var name="application.ApplicationVar" expr="'application'"/>
-->
<var name="ApplicationVar" expr="'application'"/>
<form id="F1">
<var name="DialogVar" expr="'dialog'"/>
<block>
<prompt>
here we have a <value expr="DialogVar"/> scoped variable.
</prompt>
<goto next="#F2"/>
</block>
</form>
<form id="F2">
<block>
<var name="AnonVar" expr="'anonymous'"/>
<prompt>
Our anonymous scoped variable is available here,
<value expr="AnonVar"/>, but our dialog variable will equate
to undefined. However, our <value expr="DocumentVar"/>
scoped variable is still considered active.
</prompt>
<!--
IF WE OUTPUT THIS VARIABLE WITHIN THIS SCOPE,
WE WILL GET AN ERROR.SEMANTIC, AS THIS VAR
IS NO LONGER AVAILABLE
<log expr="DialogVar"/>
-->
<goto next="Page2.cfm"/>
</block>
</form>
</vxml>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0" application="Page1.cfm">
<meta name="maintianer" content="yourEmail@here.com"/>
<form id="F1">
<block>
<prompt>
and here our <value expr="application.ApplicationVar"/> scoped
variable is available throughout the entire application. But our anonymous
scoped variable and our dialog scoped variable are no longer available.
</prompt>
<!--
IF WE OUTPUT THESE VARIABLES WITHIN THIS SCOPE,
WE WILL GET AN ERROR.SEMANTIC, AS THESE VARS
ARE NO LONGER AVAILABLE
<log expr="Anon"/>
<log expr="DialogVar"/>
-->
<log expr="DocumentVar"/>
</block>
</form>
</vxml>
| ANNOTATIONS: EXISTING POSTS |
jongmagno
|
|
| how do you assign a value to a variable from a user input? | |
mikethompson
|
|
| Hi Jong,
You can assign values to user input simply by using slot values within your grammars. I could hit you with some example code but I see a perfect example located in our GSL documentation. You can find that here: http://docs.voxeo.com/voicexml/2.0/gslmultislot.htm This will give you an in depth look at Multi-slot grammars. Hope this helps, Mike Thompson Voxeo Extreme Support |
|
appalachiangypsy
|
|
| This tutorial is awesome. I found the info I needed. Thanks. | |
bsmith
|
|
| Thank you for the feedback! We always appreciate what our customers have to say.
Thanks again, Ben Smith Voxeo Corporation |
|
SSA_MarkPMiller
|
|
| Simple typo in example code:
The second document references a non-existant root application document. The root doc is named "Page1.vxml" and the second page references 'application="Page1.cfm"' Also, the goto in the first doc references a .cfm file when it should be a .vxml file as named in the code. Mark |
|
mikethompson
|
|
| Mark,
Good catch! :) This is defintely a mix up. I imagine Matt was using .cfm for no-caching headers when he was building the application for this tutorial. I'll certainly let him know of this slip up here and have him make any changes needed. Best, Mike Thompson Voxeo Corporation |
|
sarika
|
|
| Hello,
How can i access vxml declared variable in php code or how can i access php variable in voicexml code within the same document? |
|
raghu.ram
|
|
| looking answer for thr above question.....
-rag |
| login |
|