<choice>

Defines a choice item in a menu.

Syntax

<choice
    accept = "{exact|approximate}"
    dtmf = "CDATA"
    event = "identifier"
    eventexpr = "CDATA"
    expr = "CDATA"
    fetchaudio "URI"
    fetchhint = {prefetch | safe}
    fetchtimeout = "CDATA"
    maxage "CDATA"
    maxstale "CDATA"
    message "CDATA"
    messageexpr "CDATA"
    next"URI"
/>

Attributes

Attribute

Data Type

Required?

Default

Description

accept

{exact | approximate}

no

exact

Determines how the choice is activated. Valid values:

  • approximate = Utterances containing a sub-phrase of the choice phrase activate the choice.

  • exact = Utterances that match the entire choice phrase activate the choice.

dtmf

CDATA

no

NA

DTMF grammar assigned to the choice.

event

identifier

no

NA

Event raised by the choice.

eventexpr

CDATA

no

NA

ECMAScript expression that evaluates to the event to raise.

expr

CDATA

no

NA

ECMAScript expression that evaluates to the next URI to load.

fetchaudio

URI

no

NA

URI of an audio resource to play while the XML data is fetched. If the fetchaudio attribute is not set, no audio is played during the fetch. If the audio is playing after the XML document is fetched, the audio terminates.

fetchhint

{prefetch | safe}

no

NA

Specifies when the VoiceXML Interpreter context should retrieve content from the server. Valid values:

  • prefetch = Fetch the resource when the page is loaded.

  • safe = Fetch the resource when it is specifically called by the application.

fetchtimeout

CDATA

no

NA

Interval to wait for the content to be returned before throwing an error.badfetch event. Use s for seconds (for example, 1s) and ms for milliseconds (for example, 1ms).

maxage

CDATA

no

NA

Maximum acceptable age, in seconds, of a resource being fetched from the cache. Setting maxage to 0 means that a cached version is never considered fresh.

maxstale

CDATA

no

NA

Maximum acceptable staleness, in seconds, of the resource being fetched, if the fetched resource is cached and expired.

message

CDATA

no

NA

Additional information about the event being raised. The message is available as the ECMAScript variable _message in the <catch> element that handles the event.

messageexpr

CDATA

no

NA

ECMAScript expression that evaluates to the message.

next

URI

no

NA

URI of the next dialog or document to load.

Details

You can associate speech, DTMF grammars, or both with the choice. When the choice is selected, the VoiceXML Interpreter can:

Parent

<menu>

Children

<audio>, <break>, <enumerate>, <grammar>, <mark>, <p>, <phoneme>, <prosody>, <s>, <say-as>, <value>

Example

<?xml version="1.0"?>
    'http://dtd.vision.com/voice/2.1/vision_voicexml-2.1.dtd'>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
    <catch event="quitEvent">
        Goodbye
        <exit/>
    </catch>
    <menu id="main">
        <prompt>What do you want to eat, apple or orange?</prompt>
            <choice dtmf="1" next="#formApple"> apple </choice>
            <choice expr="'#' + 'formOrange'"> orange </choice>
            <choice event="quitEvent"> quit </choice>

            <nomatch>Please say apple, orange, or quit</nomatch>
    </menu>
        <form id="formApple">
            <block>
                You chose apple
                <exit/>
            </block>
        </form>
        
        <form id="formOrange">
            <block>
                You chose orange
                <exit/>
            </block>
        </form>
</vxml>

See Also

<enumerate>, <link> , <menu>, <option>