January 18, 2021
Hot Topics:

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

  • By Developer.com Staff
  • Send Email »
  • More Articles »

Wrox Press Book - Early Adopter VoiceXML
Chapter 7, VoiceXML with XSLT (HTML and WML), Part3

WROX Press' New VoiceXML book In this chapter, all the grammars are inline, but XSLT could just as easily be used to create standalone external grammars in separate files, or to generate grammars in multiple formats (GSL, JSGF, XML) from a common data source, by the application of different stylesheets.

Just as we iterated over the order_history/order node-set to create grammars with options for all the orders of a customer, we must now iterate over these nodes again to create individual forms containing the details for each order.

<xsl:for-each select="order_history/order">       
order number 
<xsl:value-of select="position()"/> | 
buy me     
<assign name="form_pointer" 
<assign name="user_command" 
<goto next="#navigator"/>     
If there were consistently a very large number of orders per user, we might look at generating the order details on the fly using JSP or PHP to create a separate VoiceXML document.
<xsl:for-each select="order_history/order"> 
<xsl:variable name="order_detail_counter" 
<form id="order_{$order_detail_counter}">
The block above illustrates the other way XSLT offers for including dynamic content in an attribute value, this time through the <xsl:variable> element, the value of which can be output by preceding the identifier with the dollar sign, $. This technique is used several times when creating the VoiceXML forms for each order.
<!-- This falls through to order status top level -->     
<assign name="user_command" expr="'order status'"/>     
<goto next="#navigator"/>   
<goto next="#errorHandler"/>   
<assign name="form_pointer" 
<field name="userSaid">

Page 1 of 5

This article was originally published on March 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