Larson Technical Services: Voice Technology Consulting

Exercise 2.2

A VoiceXML form that reuses the grammars month.grxml, day.grxml, and year.grxml that solicits a date.


<?vxml version="1.0"?>
<vxml version="2.0">  

<!-- Solicit date using month, day, and year grammars   -->

<form id = "date">
<field  name = "month">
     <prompt> What month? </prompt>
          <grammar type="application/grammar+xml" version="1.0">
               <rule id = "month" scope = "public">
                    <one-of>
                         <item tag="january">january</item>
                         <item tag="february">february</item>
                         <item tag="march">march</item>
                         <item tag="april">april</item>
                         <item tag="may">may</item>
                         <item tag="june">june</item>
                         <item tag="july">july</item>
                         <item tag="august">august</item>
                         <item tag="september">september</item>
                         <item tag="october">october</item>
                         <item tag="november">november</item>
                         <item tag="december">december</item>
                    </one-of>
               </rule>
          </grammar>
</field>

<field name = "day">
     <prompt> What day of the month? </prompt>
          <grammar type="application/grammar+xml" version="1.0">
               <rule id = "day" scope = "public">
                    <one-of>
                         <item tag="1">one</item>
                         <item tag="2">two</item>
                         <item tag="3">three</item>
                         <item tag="4">four</item>
                         <item tag="5">five</item>
                         <item tag="6">six</item>
                         <item tag="7">seven</item>
                         <item tag="8">eight</item>
                         <item tag="9">nine</item>
                         <item tag="10">ten</item>
                         <item tag="11">eleven</item>
                         <item tag="12">twelve</item>
                         <item tag="13">thirteen</item>
                         <item tag="14">fourteen</item>
                         <item tag="15">fifteen</item>
                         <item tag="16">sixteen</item>
                         <item tag="17">seventeen</item>
                         <item tag="18">eighteen</item>
                         <item tag="19">nineteen</item>
                         <item tag="20">twenty</item>
                         <item tag="21">twenty one</item>
                         <item tag="22">twenty two</item>
                         <item tag="23">twenty three</item>
                         <item tag="24">twenty four</item>
                         <item tag="25">twenty five</item>
                         <item tag="26">twenty six</item>
                         <item tag="27">twenty seven</item>
                         <item tag="28">twenty eight</item>
                         <item tag="29">twenty nine</item>
                         <item tag="30">thirty</item>
                         <item tag="31">thirty one</item>
                    </one-of>
               </rule>
          </grammar>
</field>

<field name = "year">
     <prompt> What year? </prompt>
          <grammar type="application/grammar+xml" version="1.0">
               <rule id = "year" scope = "public">
                    <one-of>
                         <item tag="2000">two thousand</item>
                         <item tag="2001">two thousand one</item>
                         <item tag="2002">two thousand two</item>
                         <item tag="2003">two thousand three</item> 
                         <item tag="2004">two thousand four</item>
                    </one-of>
               </rule>
          </grammar>
</field>
</form>
</vxml>

Return to the Instructor’s Page

Comments are off for this post