January 19, 2021
Hot Topics:

Excerpt: Early Adopter VoiceXML: VoiceXML with XSLT (HTML and WML), Part 2

  • By Developer.com Staff
  • Send Email »
  • More Articles »
<goto next="#navigator"/>   
<goto next="#errorHandler"/>   
<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"> 
customer_record/order_history/order) != 0">
This is a list of all your orders. 
customer_record/order_history/order) = 0">
You have not placed any orders within the last thirty days. 
<break msecs="500"/>
Note, the lines ("test=") in the above code are only broken to display on this page--in actuality they would not be broken.

The next block creates a prompt for each order that was in the source XML document by using the XSLT element <xsl:for-each> to select XML elements that match the XPath in its attribute. The sayas attribute from the <order_date> element in our XML file is used here to provide an audio cue to identify the order to the user.

<xsl:for-each select="order_history/order">       
<sayas class="date">       
<xsl:value-of select="order_date/@sayas"/>,       
you placed an order. Say order number       
<xsl:value-of select="position()"/>       
to hear more about it.       
<break msecs="500"/> 
<grammar type="application/x-jsgf">       
list |       
product list |       
more information |       
frequently asked questions |       
questions |       
order status |
The grammar also includes an option dynamically generated by the XSLT code. The user can say, "order number one" to access data on the first order in their list. This JSGF could be improved to accept shorter instructions, such as "order one", or even "one", but be aware that using "order number" followed by the number will help the ASR system correctly identify the user utterance, and will probably improve application performance in this situation.

Join us next week for the rest of Chapter 7 from Early Adopter VoiceXML.

This book excerpt comes to us from WROX Press--technical books that you can count on!

Page 5 of 5

This article was originally published on February 14, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date