Contents:



XML Schema: GRAMMAR

Quick-links: [Elements] [Attributes] [Source]

This schema describes the SAPI 5.0 SR Command and Control grammar format which is based on the XML framework. The schema is included in the speech grammar compiler tool (gramcomp.exe or gc.exe) and does not need to be included in your grammar files. It is provided as a reference document. NOTE: This schema is based on the Microsoft schema language and is not fully W3C compliant. This schema will be rewritten and will be compliant with the W3C standard once it has been approved by the W3C.

This schema describes the following elements and attributes:

Elements Attributes Element-specific Attributes
<DEFINE>
<DICTATION>
<GRAMMAR> (document element)
<ID>
<L>
<LIST>
<O>
<OPT>
<P>
<PHRASE>
<RESOURCE>
<RULE>
<RULEREF>
<TEXTBUFFER>
<WILDCARD>
DISP
DYNAMIC
EXPORT
ID
INTERPRETER
LANGID
LEXDELIMITER
MAX
MIN
NAME
OBJECT
PRON
PROPID
PROPNAME
REFID
TOPLEVEL
URL
VAL
VALSTR
WEIGHT
WORDTYPE

Document conventions:

GRAMMAR Elements

<DEFINE>
The DEFINE tag contains a group of ID tags.
syntax: <DEFINE >
  (many)
  <ID> +
</DEFINE>
content: eltOnly
order: many (default)
parents: GRAMMAR
children: ID
attributes: (none)
model: open
source:
<ElementType name="DEFINE" content="eltOnly" model="open">
	<description>The DEFINE tag contains a group of ID tags.</description>
	<element type="ID" minOccurs="1" maxOccurs="*"/>
</ElementType>
<DICTATION>
Specifies that the recognized phrase should match at least MIN and at most MAX words from the dictation grammar. The DICTATION tag may contain an associated semantic tag (name/value pair) which will be returned if the DICTATION tag is recognized.
syntax: <DICTATION
 [ MAX = string ]
 [ MIN = string ]
 [ PROPID = string ]
 [ PROPNAME = string ]
/>
content: empty
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: (none)
attributes: MAX, MIN, PROPID, PROPNAME
model: open
source:
<ElementType name="DICTATION" content="empty" model="open">
	<description>Specifies that the recognized phrase should match at least MIN and at most MAX words from the dictation grammar. The DICTATION tag may contain an associated semantic tag (name/value pair) which will be returned if the DICTATION tag is recognized.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="MIN"/>
	<attribute type="MAX"/>
</ElementType>
<GRAMMAR>
The top-level XML element containing all other XML elements needed to declare one Command and Control grammar.
syntax: <GRAMMAR
  LANGID = int
 [ LEXDELIMITER = string ]
 [ WORDTYPE = BSTR ]
>
  (many)
<DEFINE> ]
  <RULE> +
</GRAMMAR>
content: eltOnly
order: many (default)
parents: No parents found. This is probably the document element.
children: DEFINE, RULE
attributes: LANGID, LEXDELIMITER, WORDTYPE
model: closed
source:
<ElementType name="GRAMMAR" content="eltOnly" model="closed">
	<description>The top-level XML element containing all other XML elements needed to declare one Command and Control grammar.</description>
	<attribute type="LANGID"/>
	<attribute type="WORDTYPE"/>
	<attribute type="LEXDELIMITER"/>
	<element type="DEFINE" minOccurs="0" maxOccurs="1"/>
	<element type="RULE" minOccurs="1" maxOccurs="*"/>
</ElementType>
<ID>
The ID tag defines named constants for rule ID, property value, and property ID elements.
syntax: <ID
 [ NAME = string ]
 [ VAL = string ]
/>
content: empty
order: one
parents: DEFINE
children: (none)
attributes: NAME, VAL
model: open
source:
<ElementType name="ID" content="empty" model="open" order="one">
	<description> The ID tag defines named constants for rule ID, property value, and property ID elements.</description>
	<attribute type="NAME"/>
	<attribute type="VAL"/>
</ElementType>
<L>
Defines an expression of alternate phrase recognitions. Each subelement represents a possible separate recognition in place of this element. It is a synonym of the LIST tag. Emply elements are not valid (i.e. the tag must have children). The LIST element can define a default property name (PROPNAME) or id (PROPID) which will be inherited by it's child PHRASE elements.
syntax: <L
 [ PROPID = string ]
 [ PROPNAME = string ]
>
  (many)
<RULEREF> ] *
<PHRASE> ] *
<P> ] *
<L> ] *
<LIST> ] *
<TEXTBUFFER> ] *
<WILDCARD> ] *
<DICTATION> ] *
</L>
content: eltOnly
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: DICTATION, L, LIST, P, PHRASE, RULEREF, TEXTBUFFER, WILDCARD
attributes: PROPID, PROPNAME
model: open
source:
<ElementType name="L" content="eltOnly" model="open">
	<description>Defines an expression of alternate phrase recognitions. Each subelement represents a possible separate recognition in place of this element. It is a synonym of the LIST tag. Emply elements are not valid (i.e. the tag must have children). The LIST element can define a default property name (PROPNAME) or id (PROPID) which will be inherited by it's child PHRASE elements.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<element type="RULEREF" minOccurs="0" maxOccurs="*"/>
	<element type="PHRASE" minOccurs="0" maxOccurs="*"/>
	<element type="P" minOccurs="0" maxOccurs="*"/>
	<element type="L" minOccurs="0" maxOccurs="*"/>
	<element type="LIST" minOccurs="0" maxOccurs="*"/>
	<element type="TEXTBUFFER" minOccurs="0" maxOccurs="*"/>
	<element type="WILDCARD" minOccurs="0" maxOccurs="*"/>
	<element type="DICTATION" minOccurs="0" maxOccurs="*"/>
</ElementType>
<LIST>
Defines an expression of alternate phrase recognitions. Each subelement represents a possible separate recognition in place of this element. It is a synonym of the L tag. Emply elements are not valid (i.e. the tag must have children). The LIST element can define a default property name (PROPNAME) or id (PROPID) which will be inherited by it's child PHRASE elements.
syntax: <LIST
 [ PROPID = string ]
 [ PROPNAME = string ]
>
  (many)
<RULEREF> ] *
<PHRASE> ] *
<P> ] *
<L> ] *
<LIST> ] *
<TEXTBUFFER> ] *
<WILDCARD> ] *
<DICTATION> ] *
</LIST>
content: eltOnly
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: DICTATION, L, LIST, P, PHRASE, RULEREF, TEXTBUFFER, WILDCARD
attributes: PROPID, PROPNAME
model: open
source:
<ElementType name="LIST" content="eltOnly" model="open">
	<description>Defines an expression of alternate phrase recognitions. Each subelement represents a possible separate recognition in place of this element. It is a synonym of the L tag. Emply elements are not valid (i.e. the tag must have children). The LIST element can define a default property name (PROPNAME) or id (PROPID) which will be inherited by it's child PHRASE elements.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<element type="RULEREF" minOccurs="0" maxOccurs="*"/>
	<element type="PHRASE" minOccurs="0" maxOccurs="*"/>
	<element type="P" minOccurs="0" maxOccurs="*"/>
	<element type="L" minOccurs="0" maxOccurs="*"/>
	<element type="LIST" minOccurs="0" maxOccurs="*"/>
	<element type="TEXTBUFFER" minOccurs="0" maxOccurs="*"/>
	<element type="WILDCARD" minOccurs="0" maxOccurs="*"/>
	<element type="DICTATION" minOccurs="0" maxOccurs="*"/>
</ElementType>
<O>
This element is similar to the P element. The only difference between the PHRASE element and the OPT element is that the OPT element need not be recognized for the rule to be fired. An associated property name and value pair will be generated only if the contents of this element are recognized. It is a synonym for the OPT tag.
syntax: <O
 [ DISP = string ]
 [ MAX = string ]
 [ MIN = string ]
 [ PRON = string ]
 [ PROPID = string ]
 [ PROPNAME = string ]
 [ VAL = string ]
 [ VALSTR = string ]
 [ WEIGHT = float ]
>
  (many)
<RULEREF> ] *
<PHRASE> ] *
<P> ] *
<L> ] *
<LIST> ] *
<O> ] *
<OPT> ] *
<TEXTBUFFER> ] *
<WILDCARD> ] *
<DICTATION> ] *
  mixed content
</O>
content: mixed
order: many (default)
parents: O, OPT, P, PHRASE, RULE
children: DICTATION, L, LIST, O, OPT, P, PHRASE, RULEREF, TEXTBUFFER, WILDCARD
attributes: DISP, MAX, MIN, PRON, PROPID, PROPNAME, VAL, VALSTR, WEIGHT
model: open
source:
<ElementType name="O" content="mixed" model="open">
	<description>This element is similar to the P element. The only difference between the PHRASE element and the OPT element is that the OPT element need not be recognized for the rule to be fired. An associated property name and value pair will be generated only if the contents of this element are recognized. It is a synonym for the OPT tag. </description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="VAL"/>
	<attribute type="VALSTR"/>
	<attribute type="PRON"/>
	<attribute type="DISP"/>
	<attribute type="MIN"/>
	<attribute type="MAX"/>
	<attribute type="WEIGHT"/>
	<element type="RULEREF" minOccurs="0" maxOccurs="*"/>
	<element type="PHRASE" minOccurs="0" maxOccurs="*"/>
	<element type="P" minOccurs="0" maxOccurs="*"/>
	<element type="L" minOccurs="0" maxOccurs="*"/>
	<element type="LIST" minOccurs="0" maxOccurs="*"/>
	<element type="O" minOccurs="0" maxOccurs="*"/>
	<element type="OPT" minOccurs="0" maxOccurs="*"/>
	<element type="TEXTBUFFER" minOccurs="0" maxOccurs="*"/>
	<element type="WILDCARD" minOccurs="0" maxOccurs="*"/>
	<element type="DICTATION" minOccurs="0" maxOccurs="*"/>
</ElementType>
<OPT>
This element is similar to the PHRASE element. The only difference between the PHRASE element and the OPT element is that the OPT element need not be recognized for the rule to be fired. An associated property name and value pair will be generated only if the contents of this element are recognized. It is a synonym for the O tag.
syntax: <OPT
 [ DISP = string ]
 [ MAX = string ]
 [ MIN = string ]
 [ PRON = string ]
 [ PROPID = string ]
 [ PROPNAME = string ]
 [ VAL = string ]
 [ VALSTR = string ]
 [ WEIGHT = float ]
>
  (many)
<RULEREF> ] *
<PHRASE> ] *
<P> ] *
<L> ] *
<LIST> ] *
<O> ] *
<OPT> ] *
<TEXTBUFFER> ] *
<WILDCARD> ] *
<DICTATION> ] *
  mixed content
</OPT>
content: mixed
order: many (default)
parents: O, OPT, P, PHRASE, RULE
children: DICTATION, L, LIST, O, OPT, P, PHRASE, RULEREF, TEXTBUFFER, WILDCARD
attributes: DISP, MAX, MIN, PRON, PROPID, PROPNAME, VAL, VALSTR, WEIGHT
model: open
source:
<ElementType name="OPT" content="mixed" model="open">
	<description>This element is similar to the PHRASE element. The only difference between the PHRASE element and the OPT element is that the OPT element need not be recognized for the rule to be fired. An associated property name and value pair will be generated only if the contents of this element are recognized. It is a synonym for the O tag.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="VAL"/>
	<attribute type="VALSTR"/>
	<attribute type="PRON"/>
	<attribute type="DISP"/>
	<attribute type="MIN"/>
	<attribute type="MAX"/>
	<attribute type="WEIGHT"/>
	<element type="RULEREF" minOccurs="0" maxOccurs="*"/>
	<element type="PHRASE" minOccurs="0" maxOccurs="*"/>
	<element type="P" minOccurs="0" maxOccurs="*"/>
	<element type="L" minOccurs="0" maxOccurs="*"/>
	<element type="LIST" minOccurs="0" maxOccurs="*"/>
	<element type="O" minOccurs="0" maxOccurs="*"/>
	<element type="OPT" minOccurs="0" maxOccurs="*"/>
	<element type="TEXTBUFFER" minOccurs="0" maxOccurs="*"/>
	<element type="WILDCARD" minOccurs="0" maxOccurs="*"/>
	<element type="DICTATION" minOccurs="0" maxOccurs="*"/>
</ElementType>
<P>
This element is used to describe the Phrase element. It is a synonym of the PHRASE element. An associated property name and value pair will be generated only if the contents of this element are recognized. It is important to note that a P empty element is not allowed.
syntax: <P
 [ DISP = string ]
 [ MAX = string ]
 [ MIN = string ]
 [ PRON = string ]
 [ PROPID = string ]
 [ PROPNAME = string ]
 [ VAL = string ]
 [ VALSTR = string ]
 [ WEIGHT = float ]
>
  (many)
<RULEREF> ] *
<PHRASE> ] *
<P> ] *
<L> ] *
<LIST> ] *
<O> ] *
<OPT> ] *
<TEXTBUFFER> ] *
<WILDCARD> ] *
<DICTATION> ] *
  mixed content
</P>
content: mixed
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: DICTATION, L, LIST, O, OPT, P, PHRASE, RULEREF, TEXTBUFFER, WILDCARD
attributes: DISP, MAX, MIN, PRON, PROPID, PROPNAME, VAL, VALSTR, WEIGHT
model: open
source:
<ElementType name="P" content="mixed" model="open">
	<description> This element is used to describe the Phrase element. It is a synonym of the PHRASE element. An associated property name and value pair will be generated only if the contents of this element are recognized. It is important to note that a P empty element is not allowed.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="VAL"/>
	<attribute type="VALSTR"/>
	<attribute type="PRON"/>
	<attribute type="DISP"/>
	<attribute type="MIN"/>
	<attribute type="MAX"/>
	<attribute type="WEIGHT"/>
	<element type="RULEREF" minOccurs="0" maxOccurs="*"/>
	<element type="PHRASE" minOccurs="0" maxOccurs="*"/>
	<element type="P" minOccurs="0" maxOccurs="*"/>
	<element type="L" minOccurs="0" maxOccurs="*"/>
	<element type="LIST" minOccurs="0" maxOccurs="*"/>
	<element type="O" minOccurs="0" maxOccurs="*"/>
	<element type="OPT" minOccurs="0" maxOccurs="*"/>
	<element type="TEXTBUFFER" minOccurs="0" maxOccurs="*"/>
	<element type="WILDCARD" minOccurs="0" maxOccurs="*"/>
	<element type="DICTATION" minOccurs="0" maxOccurs="*"/>
</ElementType>
<PHRASE>
This element is used to describe the Phrase element. It is a synonym of the P element. An associated property name and value pair will be generated only if the contents of this element are recognized.It is important to note that an empty PHRASE element is not allowed. Attributes may not be empty.
syntax: <PHRASE
 [ DISP = string ]
 [ MAX = string ]
 [ MIN = string ]
 [ PRON = string ]
 [ PROPID = string ]
 [ PROPNAME = string ]
 [ VAL = string ]
 [ VALSTR = string ]
 [ WEIGHT = float ]
>
  (many)
<RULEREF> ] *
<PHRASE> ] *
<P> ] *
<L> ] *
<LIST> ] *
<O> ] *
<OPT> ] *
<TEXTBUFFER> ] *
<WILDCARD> ] *
<DICTATION> ] *
  mixed content
</PHRASE>
content: mixed
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: DICTATION, L, LIST, O, OPT, P, PHRASE, RULEREF, TEXTBUFFER, WILDCARD
attributes: DISP, MAX, MIN, PRON, PROPID, PROPNAME, VAL, VALSTR, WEIGHT
model: open
source:
<ElementType name="PHRASE" content="mixed" model="open">
	<description> This element is used to describe the Phrase element. It is a synonym of the P element. An associated property name and value pair will be generated only if the contents of this element are recognized.It is important to note that an empty PHRASE element is not allowed. Attributes may not be empty.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="VAL"/>
	<attribute type="VALSTR"/>
	<attribute type="PRON"/>
	<attribute type="DISP"/>
	<attribute type="MIN"/>
	<attribute type="MAX"/>
	<attribute type="WEIGHT"/>
	<element type="RULEREF" minOccurs="0" maxOccurs="*"/>
	<element type="PHRASE" minOccurs="0" maxOccurs="*"/>
	<element type="P" minOccurs="0" maxOccurs="*"/>
	<element type="L" minOccurs="0" maxOccurs="*"/>
	<element type="LIST" minOccurs="0" maxOccurs="*"/>
	<element type="O" minOccurs="0" maxOccurs="*"/>
	<element type="OPT" minOccurs="0" maxOccurs="*"/>
	<element type="TEXTBUFFER" minOccurs="0" maxOccurs="*"/>
	<element type="WILDCARD" minOccurs="0" maxOccurs="*"/>
	<element type="DICTATION" minOccurs="0" maxOccurs="*"/>
</ElementType>
<RESOURCE>
Specifies the grammar node is a grammar located in a standard Windows Resource grammar.
syntax: <RESOURCE
 [ NAME = string ]
/>
content: empty
order: many (default)
parents: RULE
children: (none)
attributes: NAME
model: open
source:
<ElementType name="RESOURCE" content="empty" model="open">
	<description> Specifies the grammar node is a grammar located in a standard Windows Resource grammar.</description>
	<attribute type="NAME"/>
</ElementType>
<RULE>
This element describes the non-terminal RULE element. The contents must be non-empty concatenated recognition contents. Left recursion is not legal in a grammar. It is required that either the NAME or ID attribute is specified. If both are specified, then they must agree. All RULE NAMEs and VALs should be unique. Dynamic rules may not be exported.
syntax: <RULE
 [ DYNAMIC = enumeration: 0 | NO | FALSE | 1 | YES | TRUE ]
 [ EXPORT = enumeration: 0 | NO | FALSE | 1 | YES | TRUE ]
 [ ID = string ]
 [ INTERPRETER = enumeration: 0 | NO | FALSE | 1 | YES | TRUE ]
 [ NAME = string ]
 [ TOPLEVEL = enumeration: INACTIVE | ACTIVE ]
>
  (many)
  many
  <RULEREF>
  <PHRASE>
  <P>
  <L>
  <LIST>
  <O>
  <OPT>
  <TEXTBUFFER>
  <WILDCARD>
  <DICTATION>
  <RESOURCE>
  *
</RULE>
content: eltOnly
order: many (default)
parents: GRAMMAR
children: DICTATION, L, LIST, O, OPT, P, PHRASE, RESOURCE, RULEREF, TEXTBUFFER, WILDCARD
attributes: DYNAMIC, EXPORT, ID, INTERPRETER, NAME, TOPLEVEL
model: open
source:
<ElementType name="RULE" content="eltOnly" model="open">
	<description> This element describes the non-terminal RULE element. The contents must be non-empty concatenated recognition contents. Left recursion is not legal in a grammar. It is required that either the NAME or ID attribute is specified. If both are specified, then they must agree. All RULE NAMEs and VALs should be unique. Dynamic rules may not be exported.</description>
	<attribute type="NAME"/>
	<attribute type="ID"/>
	<attribute type="TOPLEVEL"/>
	<attribute type="EXPORT"/>
	<attribute type="INTERPRETER"/>
	<attribute type="DYNAMIC"/>
	<group order="many" minOccurs="0" maxOccurs="*">
		<element type="RULEREF"/>
		<element type="PHRASE"/>
		<element type="P"/>
		<element type="L"/>
		<element type="LIST"/>
		<element type="O"/>
		<element type="OPT"/>
		<element type="TEXTBUFFER"/>
		<element type="WILDCARD"/>
		<element type="DICTATION"/>
		<element type="RESOURCE"/>
	</group>
</ElementType>
<RULEREF>
This element describes the RULEREF tag which is non-terminal. It is used inside the contents of a rule definition (RULE) to reference another defined rule. The RULEREF tag may contain a semantic property (name/value pair) which will be returned if the rule is recognized.
syntax: <RULEREF
 [ NAME = string ]
 [ OBJECT = string ]
 [ PROPID = string ]
 [ PROPNAME = string ]
 [ REFID = string ]
 [ URL = string ]
 [ VAL = string ]
 [ VALSTR = string ]
 [ WEIGHT = float ]
/>
content: empty
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: (none)
attributes: NAME, OBJECT, PROPID, PROPNAME, REFID, URL, VAL, VALSTR, WEIGHT
model: open
source:
<ElementType name="RULEREF" content="empty" model="open">
	<description>This element describes the RULEREF tag which is non-terminal.  It is used inside the contents of a rule definition (RULE) to reference another defined rule. The RULEREF tag may contain a semantic property (name/value pair) which will be returned if the rule is recognized.</description>
	<attribute type="NAME"/>
	<attribute type="REFID"/>
	<attribute type="OBJECT"/>
	<attribute type="URL"/>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="VAL"/>
	<attribute type="VALSTR"/>
	<attribute type="WEIGHT"/>
</ElementType>
<TEXTBUFFER>
Specifies the grammar is from a text buffer, to be specified at runtime by the application. See also ISpRecoGrammar::SetWordSequenceData and ISpRecoGrammar::SetTextSelection.
syntax: <TEXTBUFFER
 [ PROPID = string ]
 [ PROPNAME = string ]
 [ WEIGHT = float ]
/>
content: empty
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: (none)
attributes: PROPID, PROPNAME, WEIGHT
model: open
source:
<ElementType name="TEXTBUFFER" content="empty" model="open">
	<description>Specifies the grammar is from a text buffer, to be specified at runtime by the application. See also ISpRecoGrammar::SetWordSequenceData and ISpRecoGrammar::SetTextSelection.</description>
	<attribute type="PROPNAME"/>
	<attribute type="PROPID"/>
	<attribute type="WEIGHT"/>
</ElementType>
<WILDCARD>
Specifies a garbage word identifier for one or more non-silence sounds. The garbage word may be recognized by the Speech Recognition engine, but will NOT be returned to the application.
syntax: <WILDCARD />
content: empty
order: many (default)
parents: L, LIST, O, OPT, P, PHRASE, RULE
children: (none)
attributes: (none)
model: open
source:
<ElementType name="WILDCARD" content="empty" model="open">
	<description>Specifies a garbage word identifier for one or more non-silence sounds. The garbage word may be recognized by the Speech Recognition engine, but will NOT be returned to the application.</description>
</ElementType>

GRAMMAR Attributes

<... DISP="">
Specifies the display form for the given phrase tag.
syntax: [ DISP = string ]
required: no
datatype: string
elements: PHRASE, P, OPT, O
source:
<AttributeType name="DISP" dt:type="string" required="no">
	<description>Specifies the display form for the given phrase tag.</description>
</AttributeType>
<... DYNAMIC="">
Specifies that the rule can be updated (dynamically) at runtime by using the ISpGrammarBuilder API.
syntax: [ DYNAMIC = enumeration: 0 | NO | FALSE | 1 | YES | TRUE ]
required: no
datatype: enumeration
values: 0 | NO | FALSE | 1 | YES | TRUE