<rule>

New in VoiceXML 2.0. XML grammar element that defines a grammar rule.

Syntax

 <rule
     id="string"
     scope="private"|"public" 
 >
   Other Content
 </rule>

Description

This tag is used to define grammars in the XML form of the W3C Speech Recognition Grammar Format.

A <rule> element can contain any number of input elements, examples, and <tag> elements. The input elements indicate a sequence that must be matched in order.

Any contained <tag> elements apply to the entire sequence. If the user input matches the input elements, the <tag> elements are interpreted to assign values to input variables.

Any <example> elements are ignored by the speech-recognition engine.

Attribute Description
id

The name of the rule; must be unique within the containing grammar. "NULL", "VOID", or "GARBAGE" are reserved for special rules; id must not be one of these values.

scope

The scope in which this rule can be used. Optional (default is "private").

 •  private--The rule can be used only by the containing grammar
 •  public--The rule can be referenced by another grammar.

Note: Do not confuse the scope of a rule with the scope of a containing grammar. The scope of the grammar indicates where in the VoiceXML application the grammar is active.

Usage

Parents Children
<grammar>
<example>
<item>
<one-of>
<ruleref>
<tag>
<token>

See Also

 •  Speech Recognition Grammar Specification: <rule>
 •  Chapter  4, XML Speech Grammar Format in the Grammar Reference.

Examples

This rule matches one of the 3 phrases "Garibaldi", "Nassau Grouper", or "Trout":

 <rule id="fish">
    <one-of>
       <item>Garibaldi</item>
       <item>"Nassau Grouper"</item>
       <item>Trout</item> 
    </one-of>
 </rule>

This rule matches any input that ends with "trigger fish", such as "queen trigger fish", "picasso trigger fish", and "mean old trigger fish", as well as simply "trigger fish":

 <rule id="trigger">
   <ruleref special="GARBAGE"/>
   <token>Trigger Fish</token>
 </rule>

The following set of rules creates one public rule named snapper and two private rules named snapperType and fishColors:

 <rule id="snapper" scope="public">
   <ruleref uri="#snapperType"/>
   <token>Snapper</token> 
 </rule>
 
 <rule id="snapperType">
   <token>Mutton</token> 
   <ruleref uri="#fishColors"/>
 </rule>
 
 <rule id="fishColors" scope="private">
   <one-of>
     <item>Black</item>
     <item>Gray</item>
     <item>Red</item>
   </one-of>
 </rule>

[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