<value>

Inserts the value of a expression into audio output.

Syntax

 <value
     expr="js_expression"
 />

Description

Attribute Description
expr

JavaScript expression to evaluate and insert in the prompt.

Note: In VoiceXML 2.0, the recorded audio stored in the input variable of a <record> item can now be played with <audio expr="..."> . The expr attribute of <value expr="..."> is deprecated for playing recorded audio, and in the next release will no longer be able to play it.

(VoiceXML 1.0 only) The following attributes can be used in applications in which the version attribute of the <vxml> tag is set to 1.0.

Attribute Description
class
type

VoiceXML 1.0 only. The <say-as> type of the variable for interpretive purposes. Optional.

The type attribute is the VoiceXML 1.0 standard. These two attributes are identical; only one of them should be used.

Note: A VoiceXML 2.0 application should not use either of these attributes, but should instead enclose the <value> tag within a <say-as> element. There is no implicit <say-as> type invoked when you use <value>. See <say-as> for details.

The following event may be thrown during the execution of a <say-as> element:

error.badfetch--Thrown in VoiceXML 2.0 when any of the following attributes are present: class, mode or recsrc. These attributes are not valid for version 2.0.

Tip:

 •  If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "&lt;", "&gt;", or "&amp;". For more information, see JavaScript Quick Reference.

Usage

Parents Children
<audio>
<bevocal:foreach>
<bevocal:listen>
<bevocal:register>
<bevocal:verify>
<bevocal:whisper>
<block>
<catch>
<choice>
<emphasis>
<enumerate>
<error>
<field>
<filled>
<help>
<if>
<initial>
<log>
<menu>
<noinput>
<nomatch>
<p>
<paragraph>
<prompt>
<prosody>
<record>
<s>
<say-as>
<sentence>
<subdialog>
<transfer>
<voice>

None.

See Also

 •  VoiceXML 2.0 Specification: <value>
 •  Related tags: <assign>, <var>, <field>, <record>, <subdialog>, <transfer>, <block>, <initial>
 •  <say-as>

Examples

Example 1--with input variable:

 <?xml version="1.0" ?>
 <!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
  "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
 
 <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
   <form>
     <field name="state">
       <prompt>
         Do you want texas or california?
       </prompt>
       <grammar type="application/x-nuance-gsl"> 
         [ texas california ] 
       </grammar>
     </field>
     <block>
       <prompt>
         Your answer was 
         <value expr="state"/>
       </prompt> 
     </block>
   </form>
 </vxml>

Example 2--using assignment:

 <?xml version="1.0" ?>
 <!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
  "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
 
 <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
   <property name="universals" value="help" />
   <form id="myCalculator">
     <var name="result"/>
     <field name="op"> <!-- OPERATION -->
       <prompt>
         BeVocal calculator. 
         Choose add, subtract, multiply, or divide.
       </prompt>
       <grammar type="application/x-nuance-gsl">
         [add subtract multiply divide]
       </grammar>
       <help>Say add, subtract, multiply, or divide.</help>
       <filled>
         <prompt>Okay, let's <value expr="op"/> two numbers.</prompt>
       </filled>
     </field>
 
     <field name="a" type="number"> <!-- FIRST OPERAND -->
       <prompt>Whats the first number?</prompt>
       <help>
         Please say a number. This number will be used as the first operand.
       </help>
       <filled>
         <prompt><value expr="a"/></prompt>
       </filled>
     </field>
 
     <field name="b" type="number"> <!-- SECOND OPERAND -->
       <prompt>and the second number?</prompt>
       <help>
         Please say a number. This number will be used as the second operand.
       </help>
       <filled>
         <prompt><value expr="b"/> Okay.</prompt>
 
         <!-- NOW SAY THE RESULT -->
         
         <if cond="op=='add'">
           <!-- NOTE: Use Number() here in order to avoid 
            interpreting + as string concatenation! -->
           <assign name="result" expr="Number(a) + Number(b)"/>
           <prompt>
             <value expr="a"/> plus <value expr="b"/> equals 
             <value expr="result"/>
           </prompt>
           
         <elseif cond="op=='subtract'"/>
           <assign name="result" expr="a - b"/>
           <prompt>
             <value expr="a"/> minus <value expr="b"/> equals 
             <value expr="result"/>
           </prompt>
           
         <elseif cond="op=='multiply'"/>
           <assign name="result" expr="a * b"/>
           <prompt>
             <value expr="a"/> times <value expr="b"/> equals 
             <value expr="result"/>
           </prompt>
           
         <elseif cond="op=='divide'"/>
           <assign name="result" expr="a / b"/>
           <prompt>
             <value expr="a"/> divided by <value expr="b"/> equals 
             <value expr="result"/>
           </prompt>
         </if>
          <clear/>  
       </filled>
     </field>
   </form>
 </vxml>

[Show Frames]   [FIRST] [PREVIOUS] [NEXT]
BeVocal, Inc. Café Home | Developer Agreement | Privacy Policy | Site Map | Terms & Conditions
Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL