dcsimg
July 16, 2018
Hot Topics:

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

  • March 14, 2002
  • 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()"/> | 
</xsl:for-each>       
buy me     
</grammar>     
<filled>       
<assign name="form_pointer" 
expr="'productList'"/>       
<assign name="user_command" 
expr="userSaid"/>       
<goto next="#navigator"/>     
</filled>   
</field> 
</form>
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" 
select="position()"/> 
<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.
<noinput>     
<!-- This falls through to order status top level -->     
<assign name="user_command" expr="'order status'"/>     
<goto next="#navigator"/>   
</noinput>   
<nomatch>     
<goto next="#errorHandler"/>   
</nomatch>   
<block>    
<assign name="form_pointer" 
expr="'order_{$order_detail_counter}'"/>   
</block>   
<field name="userSaid">




Page 1 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

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

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

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