public final class SrgsXmlGrammarIdentifier extends java.lang.Object implements GrammarIdentifier
application/srgs+xml.| Constructor and Description |
|---|
SrgsXmlGrammarIdentifier() |
| Modifier and Type | Method and Description |
|---|---|
org.jvoicexml.xml.srgs.GrammarType |
getSupportedType()
Returns the supported media type.
|
org.jvoicexml.xml.srgs.GrammarType |
identify(GrammarDocument grammar)
Identifies the grammar specified by
grammar. |
public org.jvoicexml.xml.srgs.GrammarType identify(GrammarDocument grammar)
grammar. If
grammar could be identified a type is returned, otherwise
null.
The rules for a legal XML SRGS grammar are listed here:
A legal stand-alone XML Form grammar document must have a
legal XML Prolog [XML 2.8].
The XML prolog in an XML Form grammar comprises the XML
declaration and an optional DOCTYPE declaration referencing
the grammar DTD. It is followed by the root grammar
element. The XML prolog may also contain XML comments,
processor instructions and other content permitted by XML
in a prolog.
The version number of the XML declaration indicates which
version of XML is being used. The version number of the
grammar element indicates which version of the grammar
specification is being used "1.0" for this specification.
The grammar version is a required attribute.
The grammar element must designate the grammar namespace.
This can be achieved by declaring an xmlns attribute or an
attribute with an "xmlns" prefix. See [XMLNS] for details.
Note that when the xmlns attribute is used alone, it sets
the default namespace for the element on which it appears
and for any child elements. The namespace for XML Form
grammars is defined as http://www.w3.org/2001/06/grammar.
It is recommended that the grammar element also indicate
the location of the grammar schema (see Appendix C) via the
xsi:schemaLocation attribute from [SCHEMA1]. Although such
indication is not required, to encourage it this document
provides such indication on all of the examples:
The example contains all legal elements and attributes. The
comments are also valid, but are just there, to state the
requirement level.
Example:
<!-- required xml prolog -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- optional DOCTYPE -->
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
<!-- required grammar element -->
<grammar
<!-- required attribute -->
version="1.0"
>!-- optional root rule -->
mode="voice"
<!-- required if mode provided -->
xml:lang="fr-CA"
<!-- optional root rule -->
root="QuebecCities"
<!-- required attribute -->
xmlns="http://www.w3.org/2001/06/grammar"
>!-- optional root rule -->
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<!-- optional root rule -->
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
http://www.w3.org/TR/speech-grammar/grammar.xsd"
<!-- optional attribute -->
xml:base="http://www.example.com/another-base-file-path">
identify in interface GrammarIdentifiergrammar - The grammar to be identified.public org.jvoicexml.xml.srgs.GrammarType getSupportedType()
getSupportedType in interface GrammarIdentifier