Grammar Headers

This topic includes the following sections:

  • Required, recommended, and optional headers
  • Stand-alone grammar header example
  • Simplified header for stand-alone grammars
  • Inline grammar header example
Header/Attribute Definition Stand-Alone Grammars Inline Grammars

XML header

<?xml..?>

Required

Not applicable

XML DOCTYPE

DTD

Recommended

Not applicable

xsi:schemaLocation

xml schema

Recommended

Not applicable

xmlns

XML namespace

Required

Do not use

version

Grammar version

Must be: version = "1.0"

Must be: version = "1.0"

encoding

Character encoding

Recommended

Not applicable

mode

Grammar mode (voice or DTMF)

Required for mode="dtmf"

Required for mode="dtmf"

lang

Language

Required if mode="voice"

Required if mode="voice", but can inherit from VoiceXML application.

root

Root rule

Optional for external grammars whose rules are always referenced with a fragment reference (#). Required otherwise.

Required by the Tellme Platform.

type

MIME type

type="application/srgs+xml"

type="application/srgs+xml"

tag-format

Semantic Interpretation Tag Syntax

tag-format = "semantics/1.0" is preferred (ECMAScript)

tag-format = "semantics/1.0-literals" is also supported (string literals)

Required if <tag> element is used.

tag-format = "semantics/1.0" is preferred (ECMAScript)

tag-format = "semantics/1.0-literals" is also supported (string literals)

Required if <tag> element is used.

xml:base

Base URI for locating relative URIs in different rules.

Optional

Optional

lexicon

Pronunciation lexicon used when the lang declaration is present.

Not yet supported by the Tellme Platform.

Not yet supported by the Tellme Platform.

meta

Metadata tag. Allows user to specify an http-equiv property. Differs from the XML metadata declaration.

Optional; multiple allowed.

Not applicable

metadata

XML metadata tag for placing document information in a metadata scheme.

Optional

Not applicable

Stand-alone grammar header example

<?xml version="1.0" encoding="UTF-8"?> 
<!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"
            version="1.0"
            mode="voice" 
            xml:lang="en"
            type="application/srgs+xml" 
            tag-format="semantics/1.0" 
            root="topRule">

Simplified header for stand-alone grammars

Without the DTD and schema, the stand-alone grammar header can be less complex:

<?xml version="1.0" encoding="UTF-8"?>
   <grammar xmlns="http://www.w3.org/2001/06/grammar"
            version="1.0" 
            mode="voice" 
            xml:lang="en"
            type="application/srgs+xml" 
            tag-format="semantics/1.0" 
            root="topRule">

Inline grammar header example

<grammar version="1.0" 
         mode="voice"
         xml:lang="en-US"
         type="application/srgs+xml" 
         tag-format="semantics/1.0"
         root="topRule">