<item>
New in VoiceXML 2.0. XML grammar input element that groups tokens or elements in a rule. Identifies one of a set of alternatives and serves as an easy way to associate attributes with a set of rule pieces.
Syntax
<item
repeat="M"|"M-N"|"0-1"|"M-"
repeat-prob="P"
weight="N.M"
xml:lang="lang"
>
Content
</item>
Description
This tag is used to define grammars in the XML form of the W3C Speech Recognition Grammar Format.
An <item> element can contain any number of input elements and <tag> elements. The input elements indicate a sequence that must be matched in order. The repeat attribute applies to the entire sequence, indicating that it is optional or that it may be repeated.
Any contained <tag> elements apply to the entire sequence. If the user input matches the input elements and repeat attribute, the interpreter uses the <tag> elements to assign values to input variables.
| Attribute |
Description |
repeat
|
Indicates the number of times that the contained expansion may be repeated. Optional (if omitted, the sequence of input elements must occur exactly once).
| | M The contained expansion is repeated exactly M times. M must be 0 or a positive integer. |
| | M-N The contained expansion is repeated between M and N times, (inclusive). M must be 0 or a positive integer; N must be a positive integer larger than M. For example, "3-5" declares that the contained expansion can occur exactly three, four, or five times. 0-1 is a special case, indicating that the contained expansion is optional. |
| | M- The contained expansion is repeated M times or more. M must be 0 or a positive integer. For example, "3-" declares that the contained expansion can occur 3, 4, 5 or more times. |
|
repeat-prob
|
The probability of successive repetition of the repeated expression. This attribute is ignored if the repeat attribute is not specified. Optional.
Must be in the range between 0.0 and 1.0; note that this is different from a weight attached to the entire item.
A simple example is an optional item (zero or one occurrences) with a probability, for example, of 0.6. This indicates that the chance that the item will be matched is 60% and that the chance that it will not be present is 40%.
|
weight
|
Indicates how likely the item is. Optional.
Must be a positive floating point number, such as 2, 2.5, 0.8, or .4.
A weight of 1 is equivalent to not specifying a weight. A weight larger than 1 indicates greater likelihood; a weight less than 1 indicates less likelihood.
|
xml:lang
|
The language and optional country local identifier for the item. Optional (default is the language of the enclosing element).
The accepted language identifiers are:
| | en--English |
| | en-US--United States English |
| | es--Spanish |
| | es-US--United States Spanish |
| | fr-ca--French Canadian |
This attribute allows you to mix multiple languages in the same rule. If an unsupported language is specified, an error.unsupported.language event is thrown.
|
Usage
See Also
Examples
<-- The word "angel" is optional and is not very likely to occur. -->
<item>
<item repeat="0-1" repeat-prob="0.25">angel</item>
<token>fish</token>
</item>
<-- The rule reference to digit must occur between 2 and 4 times -->
<-- and it is very likely it will occur 3 or 4 times. -->
<item repeat="2-4" repeat-prob=".8">
<ruleref uri="#digit"/>
</item>
[Show Frames] [FIRST] [PREVIOUS] [NEXT]