| CCXML 1.0-W3C Development Guide | Home | Frameset Home |
<script> element may occur in a <ccxml> element and in executable content. <transition> elements and <if> elements contain executable content.<ccxml> element are evaluated just after the document is loaded, along with the <var> and <assign> elements, in document order. Script elements in a <transition> element are evaluated as they are encountered. A <script> element in an <if> element is executed like other executable elements, as it is encountered.<script> element includes additional, platform-specific support for two features usable by the developer:
<script>
ccxmllog('this is a test = ' + event$.values.test);
</script>
JSON.stringify(object)
JSON.parse(string)
| fetchid | Data Type: (ECMAScript Expression) | Default: Optional |
| The fetchid attribute allows the developer to specify an ECMAScript expression evaluating to the fetch identifier of a completed fetch request. This value is acquired via either in a fetch with the fetchid attribute, or from the fetchid attribute of a fetch.done event. In the event that the identiier is invalid, the fetch is not completed, or if the fetched content is not valid ECMAScripot, then an error.semantic will be thrown to the CCXML interpreter. | ||
| 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. | ||
| 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. | ||
| src | Data Type: (ECMAScript Expression) | Default: none - attribute is optional |
| The src atttribute indicates the URI of the <script> to be executed. If unspecified, then the elements CDATA provides the inline content. | ||
| 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. | ||
| <?xml version="1.0" encoding="UTF-8"?> <ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml"> <script src="myScript.js" timeout="'10s'"/> <eventprocessor> <transition event="connection.alerting"> <accept/> <log expr="'***** CALL ACCEPTED *****'"/> </transition> <transition event="connection.connected"> <dialogstart src="'null://?text=' + message" type="'application/x-texttospeech'"/> </transition> <transition event="dialog.exit"> <log expr="'***** CALL EXITING *****'"/> <exit/> </transition> <transition event="error.*"> <log expr="'ERROR OCCURRED: '+ event$.name"/> <exit/> </transition> </eventprocessor> </ccxml> |
| // simple js code for CCXML example var sympathy = 'Pleased to meet you. I hope you guess my name. '; var devil = 'But, whats puzzling you is the nature of my game. hoo! hoo!'; var message = sympathy + devil; |
| ANNOTATIONS: EXISTING POSTS |
jassy0809
|
|
| Hi,
A step ahead to the sample code given, I want to return some values from the ecma script to the CCXML application and evaluate it. How to achieve this? Please give some suggestions. Thanks in advance, - Jassy |
|
MattHenry
|
|
|
Hi there, Note that the following declarations are entirely identical in terms of initializing variables: <var name="myVar" expr="'myValue'"/> var myVar ='myValue'; In order to evaluate this in the CCXML context, nothing really special needs to be done to "import" it. An example of this in action might look something like this: <transition event="myEvent" cond="myVar =='foo'"> .. </transition> <transition event="myEvent" cond="myVar =='myValue'"> .. </transition> You may also want to check out the following section of the CCXML docs which covers client side scripting in the CCXML context in a bit greater detail: http://docs.voxeo.com/ccxml/1.0-final/appendixe_ccxml10.htm Hope this helps! ~Matt |
| login |