Last reviewed: 3/23/2024 8:43:51 AM
<grammar>
A <grammar> element is the required root element of a W3C XML grammar. It defines the beginning and end of the speech rules.
Syntax
<grammar mode="string"
root="string"
tag-format="string"
version="float"
xml:base="uri"
xml:lang="langid"
xmlns="uri"
xmlns:xsi="uri"
xsi:schemaLocation="uri" />
Attributes
mode
The mode of a grammar indicates the type of input that the user agent should be detecting. The default mode is "voice" for speech recognition grammars. An alternative input mode is "dtmf" input.
root
The grammar header to optionally declare a single rule to be the root rule of the grammar.
tag-format
Defines an optional attribute that contains a tag format identifier (e.g. semantics/1.0).
version
Specifies the version of the specification to be used for the grammar and must have the value "1.0".
xml:base
Specifies a grammar's base URI explicitly.
xml:lang
Indicates the primary language contained by the grammar and optionally indicates a country.
xmlns
The URI of the SRGS XML name space.
xmlns:xsi
The URI of the SRGS XML schema instance.
xsi:schemaLocation
The URI of the SRGS XML schema.
Children
<lexicon>, <meta>, <metadata>, <rule>, and <tag>.
Parents
none
Example
The following example illustrates using a grammar element.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd">
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd"
xml:lang="En" version="1.0" mode="voice" >
<!-- This is the list of colors -->
<rule id="Color">
<one-of>
<item>red</item>
<item>blue</item>
<item>green</item>
<item>yellow</item>
<item>pink</item>
<item>purple</item>
<item>brown</item>
<item>orange</item>
</one-of>
</rule>
</grammar>