3.16 field
Element type |
field |
Attributes |
cond | expr | modal | name | slot | type |
Parents |
form |
Children |
PCDATA | audio | catch | enumerate | error | filled | grammar | help | link | noinput | nomatch | option | prompt | property | value |
Description |
Declares a field in a form. A field specifies an input item to be collected from the user after prompting the user for values that match a grammar. |
DTD
<!ELEMENT field (%audio; | %event.handler; | filled | %input; | link | option | prompt | property)* > <!ATTLIST field %item.attrs; type CDATA #IMPLIED slot NMTOKEN #IMPLIED modal %boolean; 'false' >
Language model
Attributes
-
cond : expression = true
-
A guard condition associated with this form item, written as an ECMAScript expression. This expression must evaluate to true for the Form Interpretation Algorithm to visit this form item.
-
expr : expression = undefined
-
An ECMAScript expression defining an initial value for this form item. The Form Interpretation Algorithm will not visit a form item if its value has been set using expr until it is cleared.
-
modal : boolean = false
-
When true, only the field grammars are enabled, otherwise all active grammars are enabled.
-
name : field.name
-
The name associated with this form item. The name must be unique within the form, otherwise an error.badfetch will be thrown when the document is fetched. When the caller fills this form-item, by producing an utterance that matches that item's grammar, the value will be stored in a variable of this name visible from within the containing form element.
-
slot : NMTOKEN
-
The grammar slot name used to populate the field. If absent, the field's name is used. This is used for grammars who fill multiple fields.
-
type : CDATA
-
Shorthand for specifying one of the built-in grammars. Alternatively, grammar elements can be specified.
Children
-
event.handlers
-
These are active during the filling of this field.
-
filled elements
-
To be executed when this field is filled - i.e. when the grammar has been matched.
-
grammar elements
-
To be used to collect the user's response for this field.
-
link elements
-
These are active during the filling of this field.
-
option elements
-
These provide menu-like shorthand for a field with a finite number of valid responses.
-
prompt elements
-
To be rendered when the interpreter visits this field.
-
property elements
-
These define properties during the filling of this field.
Examples
Example 3-18 A form containing many fields
<?xml version="1.0" encoding="iso-8859-1"?> <vxml version="1.0"> <form> <field name="itemdigits" type="digits"> <prompt>Enter digit sequence.</prompt> <filled> Received digit sequence <value expr="itemdigits"/>. </filled> </field> <field name="itemboolean" type="boolean"> <prompt>Say Yes or No.</prompt> <filled> You answered <value expr="itemboolean"/>. </filled> </field> <field name="itemcurrency" type="currency"> <prompt>Say a currency and amount.</prompt> <filled> You said <value expr="itemcurrency"/>. </filled> </field> <field name="itemdate" type="date"> <prompt>Say month, date, and year.</prompt> <filled> You said <value expr="itemdate"/>. </filled> </field> <field name="itemtime" type="time"> <prompt>Say a time.</prompt> <filled> <prompt> You said <value expr="itemtime"/>. </prompt> </filled> </field> <field name="itemnum" type="number"> <prompt> Say a positive or negative decimal number. </prompt> <filled> <prompt> You said <value expr="itemnum"/>. </prompt> </filled> </field> <field name="itemphone" type="phone"> <prompt> Say any phone number and optionally an extension. </prompt> <filled> You said <value expr="itemphone"/>, test complete. </filled> </field> </form> </vxml>