<grammar>

The <grammar> element is used to provide a speech (or DTMF) grammar that:

Attributes

fetchhint This attribute is not supported.
fetchtimeout (defaults to "fetchtimeout" global property value) The timeout for fetches. Must be specified with the appropriate time units (e.g., "120s" for 120 seconds).
maxage (defaults to "grammarmaxage" global property value) Tells the platform the maximum acceptable age, in seconds, of cached grammars.
maxstale (defaults to "grammarmaxstale" global property value) Tells the platform the maximum acceptable staleness, in seconds, of expired cached grammars.
scope Either "document", which makes the grammar active in all dialogs of the current document (and relevant application leaf documents), or "dialog", to make the grammaractive throughout the current form. If omitted, the grammar scoping is resolved by looking at the parent element.
src The URI specifying the location of the grammar. Specifying the rulename within the URI is not supported. If you wish to load a particular rule from a grammar, declare that rule "public". See Section 3.2 for details.
srcexpr Dynamically determine the URI to fetch by evaluating this ECMAScript expression.
type The media type of the grammar. This value takes precedence over other possible sources of the media type (for instance, the "Content-type" field in an HTTP or RTSP exchange, or the file extension). The supported choices are "application/x-jsgf" and "application/srgs+xml".
xml:base Declares the base URI from which relative URIs are resolved.
tag-format This attribute is not supported.
version This attribute is not supported.
xml:lang The language declaration provides the language identifier that indicates the primary language contained by the grammar and optionally indicates a country or other variation.
root This attribute declares a single rule to be the root rule of the grammar. The rule declared as the root rule must be defined within the scope of the grammar. The rule declared as the root rule may be scoped as either public or private. This root attribute is required when specifying inline SRGS+XML grammars.
mode This attribute defines the type of grammar to be loaded, "dtmf" or "voice".
weight Specifies the weight of the grammar.
maxdigits Specifies the maximum digits allowed for your grammar. Can be used with the property type, termmaxdigits.

Notes

Plum DEV includes support for JSGF and SRGS+XML. The default grammar format is JSGF. Grammar types are specified using the "type" attibute. For JSGF, use "application/x-jsgf" and for SRGS+XML, use "application/srgs+xml".


Example

<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <field name="myfield">
      <!-- Multiple grammars can be specified either by including -->
      <!-- several grammar blocks within the field item or by -->
      <!-- specifying a built-in grammar with the "field" tag's -->
      <!-- "type" attribute. -->
      <grammar type="application/x-jsgf" mode="dtmf">
        ( 1 | 2 )+
      </grammar>
      <grammar type="application/x-jsgf" mode="voice">
        ( one | two )+
      </grammar>
      <prompt>
        Say or enter any number of the digits one or two.
      </prompt>
      <filled>
        You entered <value expr="myfield"/>.
      </filled>
      <nomatch>
        You did not say or enter any ones or twos.
        <reprompt/>
      </nomatch>
      <noinput>
        You did not enter anything.
        <reprompt/>
      </noinput>
    </field>
  </form>
</vxml>

The output of the above script would be:

Computer: Say or enter any number of the digits one or two.
Human: (enters DTMF-5)
Computer: You did not say or enter any ones or twos.
Computer: Say or enter any number of the digits one or two.
Human: (silently waits for prompt to timeout)
Computer: You did not enter anything.
Computer: Say or enter any number of the digits one or two.
Human: One two one two.
Computer: You entered one two one two.



Child Tags

<lexicon>, <meta>, <metadata>, <rule>



Parent Tags

<choice>, <field>, <form>, <link>, <record>, <transfer>