nomatch element
Last Updated: 08-30-2005
VoiceXML 2.0
Handles user input that is not recognized as part of the active grammar(s).

Syntax

<nomatch
cond = "ECMAScript_Expression"
count = "integer"
/>

Attributes
cond
A condition that must evaluate to true for this element to be selected by the form interpretation algorithm.
count
Used by the VoiceXML interpreter in the event handler selection process, allowing the developer to handle multiple occurrences of the nomatch event in a unique manner. The default value is 1.

Parents
field, form, initial, menu, object, record, subdialog, transfer, vxml

Children
assign, audio, break, clear, data, disconnect, enumerate, exit, foreach, goto, if, log, mark, prompt, reprompt, return, script, submit, throw, value, var

Remarks
The nomatch event handler catches the nomatch event. The Platform throws a nomatch event if a user's utterance does not match an active grammar.
The nomatch element is shorthand for a catch element with its event attribute set to "nomatch."
Prior to revision 3, if a nomatch occurs, then application.lastresult$ and the form item's shadow variables persist from the previous interaction, if any, unless utterance recording is enabled, in which case they are undefined. In revision 3 and later, if a nomatch occurs, application.lastresult$ is set and the form item's shadow variables persist from the previous interaction, if any. Thus, if a match occurs within a form item (setting both the shadow variables for that form item and application.lastresult$), then the developer clears or unassigns the form item, and then a nomatch occurs on that same form item, the shadow variables will now contain stale information from the initial match. In revision 3 and later, users should ignore form item shadow data on a nomatch and refer only to application.lastresult$.
Examples

The following example defines four nomatch event handlers. The first three handlers play a message to the user and give her another chance to provide input. The fourth handler terminates the application.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
   <link event="help">
      
      <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item weight="1.0">
                              help
                        </item>
                  </one-of>
            </rule>

      </grammar>

      
      <grammar mode="dtmf"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item>
                              0
                        </item>
                  </one-of>
            </rule>

      </grammar>

   </link>

   <form id="pick_fruit">

   <field name="fruit">
      <prompt>
      Pick a fruit
      </prompt>

      
      <grammar mode="dtmf"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item>
                              <item>
                                    1
                              </item>
                              <tag>out.fruit = "apple";</tag>
                        </item>
                        <item>
                              <item>
                                    2
                              </item>
                              <tag>out.fruit = "orange";</tag>
                        </item>
                        <item>
                              <item>
                                    3
                              </item>
                              <tag>out.fruit = "pear";</tag>
                        </item>
                  </one-of>
            </rule>

      </grammar>

      <grammar mode="voice"
         root="root_rule"
         tag-format="semantics/1.0"
         type="application/srgs+xml"
         version="1.0"
         xml:lang="en-US">
            <rule id="root_rule" scope="public">
                  <one-of>
                        <item>
                              <item>
                                    apple
                              </item>
                              <tag>out.fruit = "apple";</tag>
                        </item>
                        <item>
                              <item>
                                    orange
                              </item>
                              <tag>out.fruit = "orange";</tag>
                        </item>
                        <item>
                              <item>
                                    pear
                              </item>
                              <tag>out.fruit = "pear";</tag>
                        </item>
                        <item>
                              <one-of>
                                    <item>
                                          repeat
                                    </item>
                              </one-of>
                              <tag>out.fruit = "repeat";</tag>
                        </item>
                  </one-of>
            </rule>

      </grammar>


      <!-- handle the first nomatch for this field -->
      <nomatch count="1">
         I'm sorry. I didn't get that.
         <reprompt/>
      </nomatch>

      <!-- handle the second nomatch for this field -->
      <nomatch count="2">
         I'm sorry. I still didn't get that. Please say apple, orange or pear.
      </nomatch>

      <!-- handle the third nomatch for this field -->
      <nomatch count="3">
         I must be losing it because I still didn't get that. 
         Let's try this another away. 
         For an apple, press 1. 
         For an orange, press 2.
         For a pear, press 3.
      </nomatch>

      <!-- handle the fourth and final nomatch for this field -->
      <nomatch count="4">
         <exit />
      </nomatch>

      <!-- handle all noinput events for this field -->
      <noinput>
         I'm sorry. I didn't hear you.
         <reprompt/>
      </noinput>

      <!-- handle all help events for this field -->
      <help>
         Say apple, orange, or pear.
      </help>

      <filled>
      <log>Recognized <value expr="fruit"/></log>
      <if cond="'repeat' == fruit">
         <clear namelist="fruit"/>
         <reprompt/>
      <else/>
         you chose <value expr="fruit"/>
         <exit />
      </if>
      </filled>

      </field>
   </form>
</vxml>


See Also
Handling Events
[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers