CCXML 1.0-W3C Development Guide Home  |  Frameset Home


<fetch>  element


The <fetch> element, used in conjunction with the <goto> element, is used to transfer execution to a separate CCXML document. The <fetch> element allows for a pre-emptive fetch and parse of the target document to ensure that it is well formed and can execute before the <goto> ever executes. Execution returns from this element immediately, and the CCXML interpreter is free to continue while the execution context parses and prepares the target document for execution. If the target is fetchable, and parseable, an event 'ccxml.fetch.done' is sent, and the <goto> may now execute normally. However, if there is a problem with the target page, the event of 'error.fetch' is thrown to the invoking document.



usage

<fetch enctype="(ECMAScript Expression)" fetchid="(variable name)" maxage="(ECMAScript Expression)" maxstale="(ECMAScript Expression)" method="(GET|POST)" namelist="STRING" next="(ECMAScript Expression)" timeout="(ECMAScript Expression)" type=" (application/ccxml+xml|text/ecmascript|text/javascript/text/xml+e4x)">


attributes

enctype Data Type: (ECMAScript Expression) Default: application/x-www-form-urlencoded
enctype specifies an ECMAScript string expression that denotes the media encoding type of the submitted document, (when the POST method is used). The only allowable value of this attribute is 'application/x-www-form-urlencoded', which indicates that the variables in the namelist attribute must be url-encoded.

Note: The enctype attribute should not be used in conjunction with the prepareddialogid attribute.
fetchid Data Type: (variable name) Default: Optional
The fetchid attribute is an ECMAScript expression which receives an internally generated unique string identifier to be associated with the completion event. This identifier can be tested by the fetch completion event handler to distinguish among several outstanding fetch requests.  Every fetch request will receive a unique fetch ID, even requests for the same document.
maxage Data Type: (ECMAScript Expression) Default: Optional
The maxage and maxstale attributes specify the maximum acceptable staleness, in seconds, of the resource in question. However, it is strongly advised not to rely on this attribute for cache-control; caching is always best controlled by the hosting server's response headers. If no headers are specified, then no cache control will be present, regardless of the value set for the maxage and maxstale attributes.

Note: The maxage attribute should not be used in conjunction with the prepareddialogid attribute.
maxstale Data Type: (ECMAScript Expression) Default: Optional
The maxage and maxstale attributes specify the maximum acceptable staleness, in seconds, of the resource in question. However, it is strongly advised not to rely on this attribute for cache-control; caching is always best controlled by the hosting server's response headers. If no headers are specified, then no cache control will be present, regardless of the value set for the maxage and maxstale attributes.
method Data Type: (GET|POST) Default: Optional (GET)
The method attribute specifies the HTTP method to use when sending the request. If unspecified, then the value of ‘GET’, (default) is assumed, unless the submission of multipart/form-data is encountered, in which case the implied method will be ‘POST’.

Note: The method attribute should not be used in conjunction with the prepareddialogid attribute.
namelist Data Type: STRING Default: none - attribute is optional
The namelist attribute denotes the space-separated list of variable names to be sent along with the fetch. The variables will then be available as a variable/value pair in the resultant URI querystring that is sent to the server.
next Data Type: (ECMAScript Expression) Default: none - attribute is required
This attribute simply indicates the URI of the XML document to be fetched.
timeout Data Type: (ECMAScript Expression) Default: Optional
The timeout attribute specifies the amount of time to allow the fetch attempt to be made. If the fetch is not successful by the end of the duration specified, then an error.fetch will be thrown.
type Data Type:  (application/ccxml+xml|text/ecmascript|text/javascript/text/xml+e4x) Default: Optional
The type attribute specifies the MIME type of the resource to be fetched. Allowable values are:
  • application/ccxml+xml:This specifies that the document being fetched must be a CCXML document.
  • text/ecmascript: This specifies that the fetched content must be ECMA Script.
  • text/javascript:This specifies that the fetched content must be JAVA Script.
  • text/xml+e4x:This specifies that the fetched document will contain E4X data



parents

none


children

none


code samples

<1.0 fetch -next-fetchid> sample
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml">

<var name="myFetchID" expr="'some_fetch_ID'"/>
<eventprocessor>

  <transition event="connection.alerting">
  <accept/>
  <log expr="'*** CALL ACCEPTED ***'"/>
  </transition>

  <transition event="connection.connected">
  <log expr="'*** CALL CONNECTED, STARTING FETCH ***'"/>
  <log expr="'*** FETCH1 =' + fetch1 + '***'"/>
  <fetch next="'docToFetch.xml'" fetchid="myFetchID"/>
  </transition>

  <transition event="fetch.done">
  <goto fetchid="event$.fetchid"/>
  </transition>

  <transition event="error.fetch">
  <log expr="'*** AN ERROR OCCURRED DURING THE FETCH ***'"/>
  </transition>

  <transition event="error.*">
  <log expr="'ERROR OCCURRED: '+ event$.name"/>
  <exit/>
  </transition>

</eventprocessor>
</ccxml>


<docToFetch.xml>
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml">

<eventprocessor>

  <transition event="ccxml.loaded">
  <log expr="'*** OUR NEW CCXML DOCUMENT HAS BEEN FETCHED! ***'"/>
  <exit/>
  </transition>

  <transition event="error.*" name="event$">
  <log expr="'ERROR OCCURRED: '+ event$.name"/>
  <exit/>
  </transition>
         
  </eventprocessor>

</ccxml>



additional links

W3C Specification


  ANNOTATIONS: EXISTING POSTS
mtatum111
11/20/2009 2:01 PM (EST)
When using the <fetch> element, does the transition event have to be "connection.connected"  or could it be "error.*"

Just trying to see when a <fetch> can actually be called.
VoxeoDante
11/20/2009 2:19 PM (EST)
Hello,

The <fetch> element does not have to be within the connection.connected event, however I would caution against putting a fetch within an error.* handler as getting a error.fetch could cause a loop in the document.

I hope this helps.

Regards,
Dante Vitulano
Customer Support Engineer II
Voxeo Corporation

login



© 2012 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site