<choice>
Defines a menu item. Elements within a <choice> menu item may specify a grammar to be used, along with the action to be taken and/or the event to be thrown when the choice is activated.
Attributes
This section describes the attributes you can set for this element.
Name |
Data type |
Default |
---|---|---|
(exact | approximate) |
exact |
|
CDATA |
optional |
|
NMTOKEN |
optional (only one of event, eventexpr, or next can be specified) |
|
CDATA |
optional (only one of event, eventexpr, or next can be specified) |
|
CDATA |
optional |
|
CDATA |
optional |
|
(prefetch | safe) |
optional |
|
CDATA |
optional |
|
CDATA |
optional |
|
CDATA |
optional |
|
CDATA |
optional (message or messageexpr can be specified, but not both) |
|
CDATA |
optional (message or messageexpr can be specified, but not both) |
|
CDATA |
optional (only one of event, eventexpr, or next can be specified) |
accept
The accept attribute specifies how accurately a user utterance must match the text in order to activate the choice.
- If you set this attribute to “exact” (default), the user’s utterance will only activate the choice if it matches the text in the <choice> element exactly.
- If set to “approximate”, the user’s utterance will activate the choice so long as some of the words recognized match text in the <choice> element. For example, for the prompt "American Heart Association", subphrases such as "Heart Association" or "American Heart" would be recognized.
If it is specified, the <choice> element's accept attribute overrides the <menu> element's accept attribute setting.
dtmf
The dtmf attribute assigns a DTMF sequence to the choice. The DTMF sequence can be one or more of:
- 1-9
- *
- #
event
The event attribute specifies a name for the event to be thrown when the choice is activated. This can be a standard VoiceXML event, or a custom event. In either case, the event is handled as if the event had been generated using a <throw> element. See the message and messageexpr attributes for details.
Only one of event, eventexpr, or next can be specified.
Note: You can invent an event name. If you do, make sure you supply a <catch> element with a corresponding event name to handle the event. The event is caught as _event.
eventexpr
The eventexpr attribute specifies an ECMAScript expression that evaluates to the name of the event thrown when the choice is activated.
Only one of event, eventexpr, or next can be specified.
expr
The expr attribute specifies an ECMAScript expression that evaluates to the next URI to be used when the choice is activated.
Only one of event, eventexpr, or next can be specified.
fetchaudio
The fetchaudio attribute specifies the URI of the audio file to play while waiting for a document to be fetched. If you do not specify a setting for the fetchaudio attribute, the <property> element defines a value for the fetchaudio property. If the fetchaudio property is not set (default), no audio is played during a fetch. See fetchaudio for details on resource fetching properties.
fetchhint
The fetchhint attribute determines when content is retrieved from the server. Two settings for the fetchhint attribute are possible:
- prefetch—Files or dialogs are downloaded when a page is loaded.
- safe—Files or dialogs are downloaded only when they are actually needed.
If you do not specify a setting for the fetchhint attribute, a value derived from the innermost relevant documentfetchhint <property> element is used:
<property name="documentfetchhint" value="safe"/>
fetchtimeout
The fetchtimeout attribute specifies the amount of time to wait for the content to be fetched before throwing an error.badfetch event.
The value may be specified in seconds (s) or milliseconds (ms). If no unit is specified, the value is interpreted as milliseconds by default. If no value is specified, the fetchtimeout defaults to the value set an applicable <property> element, or to the value set for the browser.loading.fetchtimeout property in the Management Station if no <property> applies. If no other default applies, the platform default of 10000 milliseconds is used.
maxage
The maxage attribute specifies the maximum amount of time a fetched resource may remain in the locale cache without requiring a server revalidation. The resource may still be used if the time specified in the maxstale attribute is greater than the maxage, but the refresh will still be triggered.
If a value for the maxage attribute is not specified, revalidation will occur after the expiration of the freshness lifetime (as defined in the RFC 2616).
maxstale
The maxstale attribute specifies the maximum amount of time a stale file remains valid before a refetch is required. The value for maxstale should be greater than that for the maxage. If a value for the maxstale attribute is not specified, the stale document is refetched.
message
The message attribute specifies a message describing the event being thrown. The event is caught as _message.
Note: Only one of the message or messageexpr attributes may be specified.
messageexpr
The messageexpr attribute specifies an ECMAScript expression that resolves to the message describing the event being thrown.
Note: Only one of the message or messageexpr attributes may be specified.
next
The next attribute specifies the URI of the dialog or document that is loaded after a user makes a choice.
Only one of event, eventexpr, or next can be specified.
Children
- Parsed character data
- <audio>
- <enumerate>
- <grammar>
- <value>
Parents
Sample code
<vxml>
<menu id="nyc_menu" dtmf="true">
<prompt>
Welcome to New York city. Please select a
borough.<enumerate> For <value expr="_prompt"/>,
press <value expr="_dtmf"/> </enumerate>
</prompt>
<choice next="http://nyc.example/manhattan.vxml">
Manhattan
</choice>
<choice next="http://nyc.example/bronx.vxml">
The Bronx
<grammar> (?the bronx) </grammar>
</choice>
<choice next="http://nyc.example/brooklyn.vxml">
<audio src="../prompts/brooklyn.wav"/>
<grammar>brooklyn</grammar>
</choice>
<choice expr="'http://nyc.example/queens.vxml'">
Queens
</choice>
<choice event="no_service_here">
Staten island
</choice>
</menu>
</vxml>