Last Updated: 11-07-2005
cond = "ECMAScript_Expression"
enctype = "encoding_type"
expr = "ECMAScript_Expression"
fetchaudio = "URI"
fetchaudioexpr = "ECMAScript_Expression"
fetchhint = "string"
fetchtimeout = "string"
maxage = "seconds"
maxstale = "seconds"
method = "string"
name = "string"
namelist = "string"
src = "URI"
srcexpr = "ECMAScript_Expression"/>
|false||The element is not executed.|
|true||The element is executed.|
|application/x-www-form-urlencoded||The data is submitted using the encoding described in Section 2.2 of RFC 1738. This results in name/value pairs sent to the server as name1=value1&name2=value2... with space characters replaced by "+" and reserved characters (like "#") replaced by "%HH" where HH is the ASCII code of the character in hexadecimal. Line breaks are encoded as "%0D%0A" - a carriage return followed by a line feed.|
|multipart/form-data||The data is submitted using the encoding described in RFC 2388. The encoding provides an efficient means for sending large quantities of binary data or text containing non-ASCII characters. When submitting a variable that references recorded audio, the enctype is automatically set to "multipart/form-data".|
|prefetch||Documents may be prefetched.|
|safe||Documents may only be fetched when needed, never before.|
|GET||The request is submitted using the GET method.|
|POST||The request is submitted using the POST method.|
|The subdialog element allows you to call a self-contained VoiceXML dialog. In addition to passing parameters to the called dialog via param elements, the called dialog can return values to the caller via the return element. Whether or not you return data from a subdialog, you should always include the return element in the dialog called by the subdialog element to properly return to the execution context of the caller.|
|Just before the subdialog is executed the VoiceXML interpreter suspends the execution context of the caller including all event handlers, grammars, links, scripts, and variables in any scope (dialog, document, application). The VoiceXML interpreter creates a new execution context for the subdialog while it executes. This context is destroyed when the subdialog returns. To share data between the caller and the subdialog, use the param and return elements.|
|The namelist, method, and enctype attributes are only relevant if the subdialog element navigates to a server-side script (e.g. CGI).|
|You typically place a subdialog in a separate VoiceXML document that does not reference the application root document of the application containing the calling dialog. If you were to reference the application root from the document containing the subdialog, all variables in the application root are reinitialized each time the subdialog is called.|
|The src and srcexpr attributes are mutually exclusive.|
|The fetchaudio and fetchaudioexpr attributes are mutually exclusive. If both of these attributes are specified an error.badfetch event is thrown.|
|If any of the fetchtimeout, fetchhint, maxage, or maxstale attributes is not specified for a subdialog element, then the value of the fetchtimeout, documentfetchhint, documentmaxage, or documentmaxstale property, respectively, is used.|
|Prior to revision 3, the interpreter ignores any undeclared variables in the namelist attribute. In revision 3 and later, the interpreter throws error.semantic if any of the variables is undeclared.|
The following example jumps to a local subdialog, fruit_picker, that asks the user to pick a piece of fruit. Once the user selects a fruit, the value is returned to the calling dialog via the namelist attribute. The calling dialog accesses the value as a property of the object named by the name attribute of the subdialog element. To see that the subdialog and its caller do not share execution contexts, run the example, check the debug log, and observe that the calling_dialog variable is reinitialized to the value "none" within the context of the subdialog even though it is set to "main" in the calling dialog before the subdialog is executed.
<?xml version="1.0"?> <vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"> <var name="calling_dialog" expr="'none'" /> <var name="user" expr="'unknown'" /> <form id="main"> <block> <assign name="calling_dialog" expr="'main'"/> <assign name="user" expr="'noah'"/> </block> <subdialog src="#fruit_picker" name="oResult"> <param name="customer" expr="document.user"/> <catch event="event.failed"> fruit picker failed </catch> <filled> fruit picker returned <value expr="oResult.fruit"/> <log>back in <value expr="calling_dialog"/></log> <exit /> </filled> </subdialog> </form> <form id="fruit_picker"> <var name="customer"/> <var name="aFruits" expr="new Array('apples', 'oranges', 'bananas', 'pears')"/> <block> <!-- calling_dialog will evaluate to 'none' because the subdialog doesn't share the execution context of the calling dialog --> <log>calling dialog is <value expr="calling_dialog"/></log> </block> <field name="fruit"> <prompt> What kind of fruit would you like, <value expr="customer"/> </prompt> <grammar mode="voice" root="root_rule" tag-format="semantics/1.0" type="application/srgs+xml" version="1.0" xml:lang="en-US"> <rule id="root_rule" scope="public"> <one-of> <item> <one-of> <item> apple </item> <item> apples </item> </one-of> <tag>out.fruit = "apple";</tag> </item> <item> <one-of> <item> orange </item> <item> oranges </item> </one-of> <tag>out.fruit = "orange";</tag> </item> <item> <one-of> <item> banana </item> <item> bananas </item> </one-of> <tag>out.fruit = "banana";</tag> </item> <item> <one-of> <item> pear </item> <item> pears </item> </one-of> <tag>out.fruit = "pear";</tag> </item> </one-of> </rule> </grammar> <catch event="noinput nomatch"> Sorry <value expr="customer"/>. I don't think we have any of those available. Our limited selection includes the following: <foreach item="f" array="aFruits"> <value expr="f"/> </foreach> Please pick one. </catch> <catch event="noinput"> Sorry <value expr="customer"/>. I didn't hear you. <reprompt/> </catch> <catch event="noinput nomatch" count="2"> Bailing. <return event="event.failed" /> </catch> <filled> <log>Recognized <value expr="fruit"/></log> <return namelist="fruit"/> </filled> </field> </form> </vxml>