org.jvoicexml.interpreter.grammar.identifier
Class SrgsXmlGrammarIdentifier

java.lang.Object
  extended by org.jvoicexml.interpreter.grammar.identifier.SrgsXmlGrammarIdentifier
All Implemented Interfaces:
GrammarIdentifier

public final class SrgsXmlGrammarIdentifier
extends Object
implements GrammarIdentifier

This class implements the GrammarIdentifier interface. An instance of this class is able to identify a SRGS grammar with XML format. The mime type of the accepted grammar is application/srgs+xml.

Version:
$Revision: 216 $

Copyright © 2005-2007 JVoiceXML group - http://jvoicexml.sourceforge.net/

Author:
Christoph Buente

Constructor Summary
SrgsXmlGrammarIdentifier()
           
 
Method Summary
 GrammarType getSupportedType()
          Returns the supported media type.
 GrammarType identify(GrammarDocument grammar)
          Identifies the grammar specified by grammar. 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].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SrgsXmlGrammarIdentifier

public SrgsXmlGrammarIdentifier()
Method Detail

identify

public GrammarType identify(GrammarDocument grammar)
Identifies the grammar specified by 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">

Specified by:
identify in interface GrammarIdentifier
Parameters:
grammar - The grammar to be identified.
Returns:
String the type of the grammar. If grammar could not be identified, null is returned.

getSupportedType

public GrammarType getSupportedType()
Returns the supported media type.

Specified by:
getSupportedType in interface GrammarIdentifier
Returns:
the supported media type.


Copyright © 2005-2007 JVoiceXML group.