VoiceXML 2.1 Development GuideHome  |  Frameset Home

  GSL Built-in Grammars  |  TOC  |  Grammar Weighting & Probability  

Multi-slot Grammars

We can also construct GSL grammars and subgrammars that return more than one interpretation value upon a successful match. This can be quite useful should we want to fill more than one variable upon a caller's utterance. In order to do this, we simply need to define a separate slot in the grammar for each value that we wish to return:

mlbteams.gsl

STANDINGS
[
  (boston ?(red sox))    { <team "Boston"> <league "American"> <division "east"> <standing "first"> }
  (new york ?yankees)    { <team "New York"> <league "American"> <division "east"> <standing "last"> }
  (toronto ?(blue jays)) { <team "Toronto"> <league "American"> <division "east"> <standing "second"> }
]


UtteranceSlot= 'team'Slot= 'league'Slot= 'division'Slot= 'standing'
(red sox) {<team "Boston"><league "American"> <division "east">} <standing "first">}


We can then access the value of each particular slot within the VoiceXML code by using the lastresult$ shadow variable in the following format:

<value expr="lastresult$.interpretation.SLOT"/>

MyExternalMultiSlot.vxml



<?xml version="1.0"?>
<vxml version="2.1">

<form id="multipleslots">

  <field name="F_1">
    <grammar src="grammar/mlbteams.gsl#STANDINGS" type="text/gsl"/>

    <prompt>Please select a baseball team.</prompt>

    <filled>
      <prompt>
        You selected <value expr="lastresult$.utterance"/>.
        They are in <value expr="lastresult$.interpretation.standing"/> place
        in the <value expr="lastresult$.interpretation.league"/> league
        <value expr="lastresult$.interpretation.division"/>.
      </prompt>
    </filled>
  </field>

</form>
</vxml>



Download the Code!

  Download the source code



  ANNOTATIONS: EXISTING POSTS
manoop
1/25/2006 8:11 AM (EST)
In the code above:

You selected <value expr="team"/>.

May need to replace "team" with "F_1$.interpretation.team".

Cheers,
Sudhanshu
MattHenry
1/25/2006 12:01 PM (EST)
Hiya Sudhanshu,

Good catch; I'll have this fixed in a jiffy.

~Matt

login
  GSL Built-in Grammars  |  TOC  |  Grammar Weighting & Probability  

© 2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site