Re: inline grammar example

On 11/03/2011 07:44 PM, Charles Hemphill wrote:
> Here is an inline grammar example.
>
> There is a high-level description of the data URI scheme at
> http://en.wikipedia.org/wiki/Data_URI_scheme.  The official definition is at
> http://tools.ietf.org/html/rfc2397.
>
> While it is possible to include inline grammars with the data URI scheme, I
> recommend support for the SRGS<grammar>  element as well.  It's much easier
> to develop and maintain and it's easier to build grammars on the fly with
> server-side scripting.  Another option would be to have the server side
> write JavaScript that creates the grammars, but that's another level of
> indirection.  Sometimes that will be handy, but often it's unnecessary
> overhead.
>
> For an inline<grammar>  element, there is the possibility of text appearing
> in the page (like the<tts>hello world</tts>  issue), but in these cases
> conditional coding can be used.  That's a typical approach as standards come
> into play.
>
> ------------------------
>
> Consider an example where you would like to select players from your roster.
> The names come from a database, so it makes sense to generate them on the
> fly.  Note that this is a very simple example and could be done in other
> ways. Please focus on the mechanisms rather than the particular example.
>
> Example1 with standard URI:
> We could write the grammar to a file and then reference the grammar via URI.
> Then we end up with file overhead and temporary files.
> <form>
>    <reco grammar="http://example.com/rosternames.xml">
>      <input type="text"/>
>    </reco>
> </form>
>
> Example2 with data URI scheme
> Note that whitespace is only allowed with base64, so we must have a really
> long string.
> <form>
>    <reco grammar='data:text/html;charset=utf-8,<?xml version="1.0"
> encoding="UTF-8"?>\r\n<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR
> 1.0//EN"\r\n
> "http://www.w3.org/TR/speech-grammar/grammar.dtd">\r\n<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-US"
> version="1.0" root="roster"><meta name="help-hint" content="room
> description"/><rule id="roster"
> scope="public"><example>Axel</example><example>Axel Eric and
> Ondrej</example><ruleref uri="#players"/><item repeat="0-1">  and<ruleref
> uri="#players"/></item></rule><rule id="players"
> scope="private"><one-of><item>David<tag>David
> </tag></item><item>Ondrej<tag>Ondrej</tag></item><item>Eric<tag>Eric
> </tag></item><item>Kasraa<tag>Kasraa</tag></item><item>Axel<tag>Axel
> </tag></item><item>Marcus<tag>Marcus</tag></item><!-- and so on up to 18
> names --></one-of></rule></grammar>'
>    >
>      <input type="text"/>
>    </reco>
> </form>
>
> Example 3 with real inline grammar:
> Much easier to read.  More easily supports server-side scripting to plug in
> names (at least for humans while developing).
> Note that the<reco>  element is the parent of both the<input>  and<grammar>
> elements.
> <form>
>    <reco>
>      <input type="text"/>
> <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-US" version="1.0"
>           root="roster">


this doesn't work. HTML doesn't have namespaces.


>    <meta name="help-hint" content="room description"/>
>    <rule id="roster" scope="public">
>      <example>Axel</example>
>      <example>Axel Eric and Ondrej</example>
>      <ruleref uri="#players"/>
>      <item repeat="0-1">
>        and
>        <ruleref uri="#players"/>
HTML parser would not understand and would, IIRC, actually expect that 
there was </ruleref> somewhere. (void elements, like <input> are special 
cases in HTML parsing)



>      </item>
>    </rule>
>    <rule id="players" scope="private">
>      <one-of>
>        <item>David<tag>David</tag></item>
>        <item>Ondrej<tag>Ondrej</tag></item>
>        <item>Eric<tag>Eric</tag></item>
>        <item>Kasraa<tag>Kasraa</tag></item>
>        <item>Axel<tag>Axel</tag></item>
>        <item>Marcus<tag>Marcus</tag></item>
>        <!-- and so on up to 18 names -->
>      </one-of>
>    </rule>
> </grammar>
>    </reco>
> </form>
>
>
>

Received on Thursday, 3 November 2011 18:00:27 UTC