Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


VoiceXML Stylesheet (con't) - Page 6

November 29, 2001

Next, we come to the mainMenu form, the primary form of the voice application. There is a form level <nomatch> element here to transfer control flow to the errorHandler form when an utterance doesn't match the grammar. This form is used for most no-match events throughout the application, to keep track of the total number of such errors that have occurred this session. The <noinput> handler here ensures the main menu is repeated when the user doesn't respond to the prompt. In a future version of the product, the designers may implement some kind of timeout to restrict the number of loops, and disconnect the user if there is no response for a long time, but this issue need not concern us now.

<form id="mainMenu">

   <nomatch>
     <goto next="#errorHandler"/>
   </nomatch>

   <noinput>
     <goto next="#mainMenu"/>

</noinput>

<block>
  <assign name="form_pointer" expr="'mainMenu'"/>
</block>

<field name="userSaid">

  <prompt bargein="true" timeout="3s">
    This is the main menu.
	<break msecs="500"/>
	You can say product list to hear a list of products.
	<break msecs="500"/>
	You can say order status to check your order status.
	<break msecs="500"/>
	You can say frequently asked questions to get more
	information.
	<break msecs="500"/>
	You can always say main menu to return to this
	menu, or help for additional help.
  </prompt>

  <grammar type="application/x-jsgf">
    list
	product list |
	more information |
	frequently asked questions |
	questions |
	order status
  </grammar>

In order to keep track of the currently active form, the global variable form_pointer is set. This could be used to implement specific navigation logic, for example, by changing the behavior of a command slightly depending on where the command originated. Once the prompt has been played, and the user has responded with an utterance matching the inline grammar, the <filled> handler for this <field> is entered. This copies the value returned by the grammar to the global variable user_command, which is used by the navigator form to direct control flow to the required form. We could also use <subdialog> and pass a parameter, but this is simpler, and sufficient for this application.

  <filled>
        <assign name="user_command" expr="userSaid"/>
      <goto next="#navigator"/>
    </filled>
  </field>
</form>

Now our main menu form is finished, we can start to implement the dialogs that provide the application's basic functionality. First up is the orderStatus form that makes the most extensive use of dynamic content generation:

<form id="orderStatus">
  <noinput>
    <assign name="user_command" expr="'main menu'"/>
  <goto next="#navigator"/>
</noinput>

<nomatch>
  <goto next="#errorHandler"/>
</nomatch>

<field name="userSaid">

We need a test here to check that the customer does indeed have outstanding orders, and play a message to that effect:

  <prompt bargein="true" timeout="1s">
<xsl:if test="count(/myrubberbands/customer_record/order_history/order)
 != 0">
  This is a list of all your orders.
</xsl:if>
<xsl:if test="count(/myrubberbands/customer_record/order_history/order)
 = 0">
You have not placed any orders within the last thirty days.
</xsl:if>
  <break msecs="500"/>

[The colored lines above are one line. They have been split for formatting purposes.]

VoiceXML Stylesheet - Page 5
Early Adopter VoiceXML
More VoiceXML Stylesheet - Page 7


Up to => Home / Authoring / Languages / XML / Adopter




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers