<choice>

Defines a menu item.

Syntax

 <choice
     accept="exact"|"approximate"
     next="URI"
     event="event"
     expr="js_expression"
     dtmf="dtmf_sequence"
     eventexpr="js_expression"
     message="String"
     messageexpr="js_expression"
     fetchhint="prefetch"|"safe"
     fetchtimeout="time_interval" 
     fetchaudio="URI" 
     maxage="time_interval" 
     maxstale="time_interval"
 >
   Choice Text
 </choice>

Description

Attribute Description
accept

New in VoiceXML 2.0. Specifies whether the default grammar generated for this <choice> element requires all words or accepts a subset of the words; overrides the accept attribute of the parent <menu> element. Optional.

 •  exact--Requires the user to say the exact phrase that appears in the <choice> element.
 •  approximate--Allows the user to say a subset of the words in the <choice> element.

Note: The default is exact if the version attribute of the containing <vxml> element specifies 2.0 or greater. For backward compatibility, the default is approximate if the version attribute is less than 2.0 or unspecified.

next

URI of the dialog or document to visit when this choice is selected. Optional (as an alternative to event or expr).

event

An event to throw when this choice is selected. Optional (as an alternative to next or expr).

expr

JavaScript expression that evaluates to a URI of the dialog or document to visit when this choice is selected. Optional (as an alternative to next or event).

dtmf

DTMF sequence that can be used to select this choice. Optional (default is no DTMF value).

eventexpr

New in VoiceXML 2.0. A JavaScript expression evaluating to the name of the event to be thrown.

message

New in VoiceXML 2.0. A message string providing additional context about the event being thrown. The message is available as the value of a variable within the scope of the <catch> element.

messageexpr

New in VoiceXML 2.0. A JavaScript expression evaluating to the message string.

fetchhint

Specifies whether the interpreter can attempt to optimize dialog interpretation by prefetching the resource. See Prefetching Resources. Optional.

fetchtimeout

Specifies the interval to wait for the resource to be returned before throwing a error.badfetch event. See Handling Fetching Delays. Optional.

fetchaudio

Specifies the URI of background audio to be played during fetching. Note that this attribute and related properties affect whether queued prompts are played first. See Background Audio for important details. Optional.

maxage

New in VoiceXML 2.0. Specifies the maximum acceptable age, in seconds, of the cached resource. See Maximum Age. Optional.

maxstale

New in VoiceXML 2.0. Specifies the maximum acceptable time, in seconds, during which an expired cached resource can still be used. See Maximum Stale Time. Optional.

One and only one of the next, expr, or event attributes must be specified.

(VoiceXML 1.0 only) The following attributes can be used in applications in which the version attribute of the <vxml> tag is set to 1.0.

Attribute Description
caching

VoiceXML 1.0 only. Specifies the caching policy for the resource being fetched. See Caching. Optional.

Used in place of the VoiceXML 2.0 attributes maxage and maxstale.

Tip:

 •  If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "&lt;", "&gt;", or "&amp;". For more information, see JavaScript Quick Reference.

Usage

Parents Children
<menu>
<grammar>

Exceptions

 •  error.badfetch - If the dtmf attribute of <menu> is true and any of the menu's <choice> tags have specified their own DTMF sequences to be something other than "*", "#" or "0".
 •  error.semantic - If not previously declared using JavaScript var within <script> or VoiceXML <var> or via being named a form item, like a <field name="foo"/>.

See Also

 •  VoiceXML 2.0 Specification: <choice>
 •  Related tag: <enumerate>, <menu>

Examples

 <?xml version="1.0" ?>
 <!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
  "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
 
 <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
   <menu>
     <prompt>
       Welcome to BeVocal.
       <enumerate>
         For the <value expr="_prompt"/> service, say <value expr="_prompt"/>
       </enumerate>
     </prompt>
     <choice accept="approximate" next="movies.vxml">movie finder</choice>
     <choice next="horoscopes.vxml">horoscopes</choice>
     <choice accept="approximate" next="news.vxml">news desk</choice>
   </menu>
 </vxml>

[Show Frames]   [FIRST] [PREVIOUS] [NEXT]
BeVocal, Inc. Café Home | Developer Agreement | Privacy Policy | Site Map | Terms & Conditions
Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL