| 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.<script> elements in a <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 use ECMAScript values to load script by specifing an ECMAScript expression that resolves to the location of the ECMAScript text. 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. 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. | ||
| src | Data Type: CDATA | 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 |
|
moonis.ahmed
|
|
| Hi,
Just wanted to know, can i use this script feature of CCXML to send the control back to my jsp page which calls the CCXML. Some help on how the syntax will look like would be helpful. Regards, Moonis |
|
voxeoJeffK
|
|
| Hello Moonis,
We may need some additional clarification to answer you correctly. Do you mean you wish to send/retrieve data from your JSP page? Ca you provide us with some more details of your goals? Regards, Jeff Kustermann Voxeo Support |
|
moshe
|
|
| The table lists the src attribute as an ECMAScript expression, and this is wrong. In the first place, this doesn't work in your 1.0 CCXML interpreter. Secondly, this is contrary to the CCXML specification, 8.2.2.2, which states "the value of the src attribute must not be an ECMAScript expression in order to allow it to be resolved at compile-time."
The proper value is CDATA. To use ECMAScript values to load scripts, use "fetch" with an ECMAScript expression that resolves to the location of the ECMAScript text, and then use script's fetchid attribute to load that fetched text. |
|
Voxeo.Van
|
|
| Thanks for bringing this to our attention Moshe. I've corrected the docs for the src attribute. If you find anything else, please let us know.
Van Vanslette Technical Writer Voxeo |
| login |