Share via


goto

goto element

Jumps to the specified URI.

Syntax

<goto 
expr = "ECMAScript_Expression"
expritem = "ECMAScript_Expression"
fetchaudio = "URI"
fetchaudioexpr = "ECMAScript_Expression"
fetchhint = "string"
fetchtimeout = "string"
maxage = "seconds"
maxstale = "seconds"
next = "URI"
nextitem = "string"
/>

Attributes

expr

An ECMAScript expression that evaluates to the URI of a document, dialog, or both.

expritem

An ECMAScript expression that evaluates to the name of a field item to navigate to within the current dialog.

fetchaudio

The URI of the audio clip to play while the interpreter fetches the resource. For complete details on the proper use of this attribute, read the fetchaudio tutorial.

fetchaudioexpr

An ECMAScript expression that evaluates to the URI used for fetchaudio. This attribute is a Tellme extension.

fetchhint

Defines when the interpreter context may retrieve documents from the server.

prefetchDocuments may be prefetched.
safeDocuments may only be fetched when needed, never before.

fetchtimeout

The time in seconds (s) or milliseconds (ms) for the VoiceXML interpreter to wait for content to be returned by the HTTP server before throwing an error.badfetch event. The fetchtimeout value is rounded down to the nearest whole second (e.g., 5700ms or 5.7s would be rounded down to 5s). If fetchtimeout has a value less than 1 second, it is reset to the default value. The default value is 15s.

maxage

Sends the max-age Cache-Control HTTP header along with the request for the specified resource. The header indicates that the document is willing to use content whose age is no greater than the specified time in seconds, unless maxstale is also provided. Voice application developers should use extreme caution when setting this attribute. If used improperly, it could have an adverse effect on the performance of your application. You should only consider using this attribute in requests for frequently changing content (e.g. dynamically generated content) hosted on a misconfigured HTTP server that you do not control. To reduce load, some HTTP servers are configured to indicate to clients that content expires some arbitrary time in the future. In that case, set the maxage attribute to 0. If you do control the HTTP server, you should instead configure the HTTP server to omit the expires header and possibly to send the Cache-Control: no-cache header. The former requires the VoiceXML interpreter to check with the server before using any cached content. The latter requires the VoiceXML interpreter to not cache the fetched resource.

maxstale

Instructs the VoiceXML interpreter to send a max-stale Cache-Control header along with the HTTP request for the specified resource. The header indicates that the document is willing to use content that has exceeded its expiration time by no more than the specified number of seconds. Voice application developers should use extreme caution when setting this attribute. If used improperly, your application may present stale content to users. If you do control the HTTP server, you should instead configure the HTTP server to send an expires header with a time in the distant future.

next

The URI of a document, a dialog, or both. To navigate to a specific dialog within a document, separate the URI to the document and the id of the dialog with a hash symbol (#).

nextitem

The name of the field item to navigate to within the current dialog.

Parents

block, catch, error, filled, foreach, help, if, noinput, nomatch, prompt

Children

None.

Remarks

When navigating to another form within the same document by setting next or expr to an empty URI reference plus fragment identifier (e.g., "#form1"), the values of variables at document scope are retained. The values of variables at dialog scope are lost when navigating to another dialog within the same document. When navigating to a different document, variables within the current document are lost. If the current and target documents share the same application root document, the values of the variables within the application root document are retained. To retain variables when navigating between documents, assign them to variables at application scope.

Use expritem or nextitem to jump to a named block or field within a dialog. If the expritem or nextitem attribute evaluates to a nonexistent form item, the interpreter throws a generic error event prior to Revision 3, or error.badfetch in Revision 3 and later.

If any of the fetchtimeout, fetchhint, maxage, or maxstale attributes is not specified for a goto element, then the value of the fetchtimeout, documentfetchhint, documentmaxage, or documentmaxstale property, respectively, is used.

To navigate to another VoiceXML document and submit data using the POST method, use the submit element.

The fetchaudio and fetchaudioexpr attributes are mutually exclusive. If both of these attributes are specified an error.badfetch event is thrown.

There is a hard limit of 100 on the number of goto transitions between listen states. Applications for which this is an imposition would typically provide a poor user experience, but an appropriate workaround is to put content into one form with multiple blocks, rather than joining multiple forms with gotos. Most applications will never come near to hitting this limit.

Examples

The following example navigates from one dialog to another within the current document.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
   <form id="form1">
      <block>
         In dialog form1
         <goto next="#form2"/>
      </block>
   </form>
   <form id="form2">
      <block>
         In dialog form2
         <exit />
      </block>
   </form>
</vxml>

The following example navigates to a dialog within another file:

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
   <form id="form1">
      <block>
         In dialog form1 of document goto2.vxml
         <goto next="goto3.vxml"/>
      </block>
   </form>
</vxml>

The following example navigates to a specific dialog within another file:

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
   <form id="form1">
      <block>
         In dialog form1 of document goto3.vxml
         <goto next="goto4.vxml#form2"/>
      </block>
   </form>
</vxml>

The following code fragment passes a query string to a server-side script.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
<form>
   <block>
      <goto next="http://machine.company.com/cgi-bin/nba.pl?team=lakers&amp;city=nyc"/>
   </block>
</form>
</vxml>

The following example fragment uses a variable to pass a query string to a server-side script.

<?xml version="1.0"?>
<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
<form>
   <block>
      <var name="server" expr="'http://machine.company.com/cgi-bin/nba.pl'"/>
      <var name="qstr" expr="'team=lakers&amp;city=nyc'"/>
      <goto expr="server + '?' + qstr"/>
   </block>
</form>
</vxml>