|VoiceXML 2.1 Development Guide||Home | Frameset Home|
|cond||Data Type: CDATA||Default: Optional (true)|
| The cond attribute specifies a Boolean expression, which must equate to ‘true’ in order for the content to be visited and executed. (Additionally, the expr attribute must also be set to ‘undefined’, see below).|
|expr||Data Type: CDATA||Default: Optional|
|The expr attribute specifies the initial value of the element; if this value is ‘undefined’, (default), then the element will be visited by the FIA and executed. If this attribute has a value other than ‘undefined’, then the element will not be visited until explicitly set to 'undefined', by use of the clear element.|
|name||Data Type: NMTOKEN||Default: Optional|
|The name attribute specifies the name of the ECMAScript form item variable. Each name assigned to an Initial element must be unique, else a fatal error.badfetch will be thrown.|
|<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" xmlns="http://www.w3.org/2001/06/vxml">
<meta name="copyright" content="2012 voxeo corporation"/>
<meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/>
<grammar xml:lang="en-us" root="TOPLEVEL">
<rule id = "TOPLEVEL">
<item> dummy </item>
<initial name="Initial_1" expr="'SomeValue'" cond="false">
this Initial form item will be skipped, as the expression
is not equal to undefined and the condition is set to false.
<grammar xml:lang="en-us" root = "myrule" mode="dtmf">
<rule id = "myrule" scope = "public">
<item> 1 <tag> out.F_1 = "1" </tag></item>
<initial name="Initial_2" cond="true" expr="">
this inital form item will get executed, as the expression
is set to undefined and the condition is set to true pressing
DTMF 1 will execute the enclosed field.
Okay, I'll ask you for information one piece at a time.
<assign name="Initial_2" expr="true"/>
Okay, the quiet type, eh?
I'll ask you for information one piece at a time.
<assign name="Initial_2" expr="true"/>
<prompt> try pressing DTMF 1.</prompt>
<prompt> congratulations, the initial test was successful.</prompt>
|ANNOTATIONS: EXISTING POSTS|
|I have a question on the <initial> element.
In the spec it has the following
This element controls the initial interaction in a mixed initiative form. Its prompts should be written to encourage the user to say something matching a form level grammar. When at least one input item variable is filled as a result of recognition during an <initial> element, the form item variable of <initial> becomes true, thus removing it as an alternative for the FIA.
Does this mean that if something is spoken, then expr="true" which causes the FIA to skip the <initial> on the next pass through? I was a little confused by the statement
When at least one input item variable is filled as a result of recognition during an <initial> element, the form item variable of <initial> becomes true, thus removing it as an alternative for the FIA.
|Also, would expr="true" or "'true'" if a spoken entry was made?|
It's not the "expr" that is set to true when a form level grammar match is made, it's the "name", which is the element's variable. Consider:
When the grammar is matched, startHere is assigned the value "true", and the next cycle of the FIA will skip it because the FIA only visits <initial> when its variable is undefined. If your program logic requires an <initial> tag to be revisited all you need do is clear the variable:
And now that will be again selected by the FIA.
hope that helps,
|One more question, as I read the spec, I have come across the following for <initial>
Note: explicit assignment of values to input item variables does not affect the value of an <initial>'s form item variable.
Does this mean that if you have already set input item variables then the <initial> element will still be executed. It sound like this is what it is saying.
For instance if we have the following where I have the field input of price set to 100, does this still mean that <initial> will be executed. I believe according to the spec it will.
<var name="price" expr="100"/>
<prompt>I will be collecting the price as well as the number
of items. You can say both now.
<field name="price" type="currency" />
<prompt>What is the price</prompt>
<field name="quantity" type="number" />
<prompt>How many </prompt>
Yes, you are correct. The <initial>'s form variable is distinct from other input variables. Whether or not the <initial> is visited is not determined by other input items.