<ruleref>

New in VoiceXML 2.0. XML grammar input element that references another rule.

Syntax

 <ruleref
     uri="URI" 
     type="MIME_type"
     xml:lang="lang"
     special="NULL"|"VOID"|"GARBAGE" 
 >
   Optional Tags
 </ruleref>

Description

This tag is used to define grammars in the XML form of the W3C Speech Recognition Grammar Format.

The referenced rule specifies user input to be matched. If the user input matches the referenced rule, any contained <tag> elements are interpreted to assign values to input variables.

You can refer to a rule from within another rule either in the same or a different grammar definition. In summary, the formats for doing so are:

Reference to a... Format

Local rule

<ruleref uri="#rulename"/>

Named rule of a grammar identified by a URI

<ruleref uri="grammarURI#rulename"/>

Root rule of a grammar identified by a URI

<ruleref uri="grammarURI"/>

Rule of a grammar identified by a URI and specifying a media type

<ruleref
   uri="grammarURI"
   type="mediaType"/>

Rule of a grammar identified by a URI and specifying a language

<ruleref
   uri="grammarURI"
   xml:lang="lang"/>

Special rule definition

<ruleref special="NULL"/>
<ruleref special="VOID"/>
<ruleref special="GARBAGE"/>

Attribute Description
uri

The URI of the referenced rule. Optional (Must provide uri or special, but not both).

May be one of the following:

 •  #ruleName--References the local rule ruleName in the contained grammar.
 •  grammarFileURI#ruleName--References the public rule ruleName in the grammar defined in the grammar file whose URI is grammarFileURI. The grammar file can be in any grammar format, not just XML.
 •  grammarFileURI--References the default rule of the grammar defined in the grammar file whose URI is grammarFileURI. The grammar file can be in any grammar format.
type

MIME type of the grammar. Optional; only relevant for a reference to a rule in another grammar file.

For such a reference, the default type is taken from the Content-type header of the returned file. If not present, the type is inferred from the URL's extension or from the contents of the grammar (for example, a file beginning with <?xml maps to application/srgs+xml). The recognized extensions are:

 •  .grxml, .xml--XML Speech Grammar
 •  .gram--ABNF Speech Grammar
 •  .gsl, .grammar--Nuance GSL
 •  .ngo--Nuance Grammar Object
 •  .jsgf--Java Speech Grammar Format

The currently supported types are:

 •  application/srgs+xml--XML Speech Grammar
 •  application/grammar+xml--XML Speech Grammar (Deprecated; support for this value will be removed from a future release)
 •  application/srgs--ABNF Speech Grammar
 •  application/grammar--ABNF Speech Grammar (Deprecated; support for this value will be removed from a future release)
 •  application/x-nuance-gsl--Nuance GSL
 •  application/x-gsl--Nuance GSL. (Deprecated; support for this value will be removed from a future release.)
 •  application/x-nuance-dynagram-binary--Nuance Grammar Object

If you specify an unsupported type, an error is thrown. This value is used only if the web server returns an unsupported grammar type.

xml:lang

The language and optional country local identifier for the rule reference. Optional (default is the language of the enclosing element).

The accepted language identifiers are:

 •  en--English
 •  en-US--United States English
 •  es--Spanish
 •  es-US--United States Spanish
 •  fr-ca--French Canadian

This attribute is only useful if the rule referred to is in the GSL format. In all other cases, the interpreter ignores this attribute. If an unsupported language is specified, an error.unsupported.language event is thrown.

special

The referenced special rule. Optional (Must provide uri or special, but not both).

 •  NULL--Rule that is automatically matched, that is, matched without the user speaking.
 •  VOID--Rule that can never be matched. Inserting VOID into a sequence automatically makes that sequence unspeakable
 •  GARBAGE--Rule that matches any speech up until the next rule match, the next token or until the end of spoken input.

Usage

Parents Children
<rule>
<item>

None.

See Also

 •  Speech Recognition Grammar Specification: <ruleref>
 •  Chapter  4, XML Speech Grammar Format in the Grammar Reference.

Examples

 // Reference to a specific rule of an external grammar
 <ruleref uri="../fish.gram#butterflies" />
 
 // Reference to the root rule of an external grammar
 <ruleref uri="http://www.myCompany.com/grammars/fish.gram" />
 
 // References with associated media types
 <ruleref 
     uri="http://www.myCompany.com/grammars/fish#butterflies"
     type="application/srgs" 
 />
 <ruleref uri="../fish" type="application/srgs" />
 
 // Reference with an associated media type and language
 <ruleref 
     uri="http://www.myCompany.com/grammars/animals#butterflies"
     type="application/x-nuance-gsl"
     xml:lang="en-US"
 />

[Show Frames]   [FIRST] [PREVIOUS] [NEXT]
BeVocal, Inc. Café Home | Developer Agreement | Privacy Policy | Site Map | Terms & Conditions
Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL