<field>
Specifies an input field within a form.
Each field entry generates associated shadow variables. See Shadow Variables for a list and discussion of the related shadow variables.
Attributes
This section describes the attributes you can set for this element.
Name |
Data type |
Default |
---|---|---|
CDATA |
optional |
|
CDATA |
optional |
|
CDATA |
optional |
|
(true | false) |
false |
|
NMTOKEN |
optional |
|
NMTOKEN |
optional |
|
CDATA |
optional |
inputexpr
The inputexpr attribute allows the VoiceXML interpreter to collect input from an expression that evaluates to a string or waveform, rather than gathering an utterance interactively from the caller. This input state behaves exactly as though the caller had spoken the input as an utterance, with the exception that the prompt queue is not flushed.
The expression can be a string, a waveform, or an "undefined" constant, as follows.
modal
The modal attribute is a Boolean value that allows you to enable or disable grammars outside the <field> element. If the modal attribute is set to false (default), then all active grammars are enabled. If the modal attribute is set to true, then only field grammars are enabled and all other grammars are temporarily disabled.
slot
The slot attribute specifies the name of the grammar slot used to fill the guard variable of the <field> element. This value defaults to the name attribute of the <field> element. If the slot value is not specified in the recognition result, the entire user utterance will fill the recognition result.
type
The type attribute specifies the VoiceXML 2.0 built-in grammar types. Voice Platform also supports Nuance-specific built-in grammar types, depending on the language. See Built-in grammar types for details.
Form item attributes
Being a form item, the <field> element also supports the following common form item attributes.
cond
The cond attribute specifies a Boolean expression that must evaluate to true before the form item is available for selection within the Form Interpretation Algorithm (FIA).
expr
The expr attribute specifies the initial value of the form item variable. The default value of the expr attribute is undefined. If you set the expr attribute to a value other than the default, you will need to clear this value before the content of the form item element can be executed.
name
The name attribute specifies the name of the form item's guard variable. The name must be unique, or a badfetch error is thrown when the document is fetched. The Form Interpretation Algorithm (FIA) initializes this variable with the value specified by the expr attribute. If the form item comes up for selection at a later time, it will be populated by the pre-defined type for that element.
Note: The resulting value is the natural language interpretation from the recognition cycle. See the slot attribute for details.
Children
- Parsed character data
- <audio>
- <catch>
- <enumerate>
- <error>
- <filled>
- <grammar>
- <help>
- <link>
- <noinput>
- <nomatch>
- <option>
- <prompt>
- <property>
- <value>
Parents
Sample code
<field name="flavor">
<prompt>What is your favorite ice cream?</prompt>
<grammar src="../grammars/ice_cream.grxml"
type="application/srgs+xml"/>
</field>