Last reviewed: 3/23/2024 8:51:47 AM
<ruleref>
A <ruleref> element is an empty element with a uri attribute that specifies the rule reference to an external or local rule.
Syntax
<ruleref uri="#ruleName" />
Attributes
uri
The rule reference as a same-document reference URI.
special
A special rulename is represented with the special attribute on a ruleref element. It is illegal to provide both the special and the uri attributes.
NULL - Defines a rule that is automatically matched: that is, matched without the user speaking any word.
VOID - Defines a rule that can never be spoken. Inserting VOID into a sequence automatically makes that sequence unspeakable.
GARBAGE - Defines a rule that may match any speech up until the next rule match, the next token or until the end of spoken input. A grammar processor must accept grammars that contain special references to GARBAGE. The behavior GARBAGE rule is implementation-specific. A user agent should be capable of matching arbitrary spoken input up to the next token but may treat GARBAGE as equivalent to NULL (match no spoken input).
type
Specifies the media type of the reference.
Children
none
Parents
Remarks
There are various forms of rule reference that are possible within and across grammar documents.
Form | Description |
---|---|
<ruleref uri="#rulename"/> | Explicit local rule reference. |
<ruleref uri="grammarURI#rulename"/"/> | Explicit reference to a named rule of a grammar identified by a URI. |
<ruleref uri="grammarURI"/> | Implicit reference to the root rule of a grammar identified by a URI. |
<ruleref uri="grammarURI#rulename" type="media-type"/> | Explicit reference to a named rule of a grammar identified by a URI with a media type. |
<ruleref uri="grammarURI" type="media-type"/> | Implicit reference to the root rule of a grammar identified by a URI with a media type. |
Several rulenames are defined to have specific interpretation and processing by a speech recognizer. A grammar must not redefine these rulenames.
Rulename | Form | Description |
---|---|---|
NULL | <ruleref special="NULL"/> | Defines a rule that is automatically matched without the user speaking any word. |
VOID | <ruleref special="VOID"/> | Defines a rule that can never be spoken. |
GARBAGE | <ruleref special="GARBAGE"/> | Defines a rule that may match any speech up until the next rule match, the next token, or until the end of spoken input. |
Example
The following example illustrates using ruleref elements.
<?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" >
<rule id="colormodel">
<ruleref uri="#color" />
<ruleref uri="#model" />
</rule>
<rule id="color>
<one-of>
<item>red</item>
<item>blue</item>
<item>green</item>
<item>silver</item>
<item>black</item>
<item>white</item>
</one-of>
</rule>
<rule id="model">
<one-of>
<item>Altima</item>
<item>Camry</item>
<item>Fusion</item>
<item>Accord</item>
<item>Malibu</item>
</one-of>
</rule>
</grammar>