| CCXML 1.0-W3C Development Guide | Home | Frameset Home |
<foreach> element is a Voxeo extension to the CCXML 1.0 specification, (which is being proposed for inclusion to the spec), that allows the developer to iterate through a set of array values, (such as the session.connections[] array). This allows a simpler shorthand than using pure ECMAScript to loop through array values.| cond | Data Type: (ECMAScript Expression) | Default: Optional |
| The cond attribute specifies an ECMAScript expression which can be evaluated to 'true' or 'false'. A condition must evaluate to 'true' in order for any enclosed operations to be performed. | ||
| item | Data Type: (variable name) | Default: Optional |
The item attribute denotes the name of the variable that stores a particular array value as it is being iterated within the loop. If this variable is not already defined, then it will be declared upon invocation of the <foreach> element and will evaluate to "item$". | ||
| name | Data Type: (variable name) | Default: Optional |
| The name attribute defines the name of the index that is to be refenced, (in this case, the connectionid). If undefined, this will contain a default value of "index$". | ||
| object | Data Type: (ECMAScript Expression) | Default: Required |
The object attribute defines the name of the array or object to enumerate by the <foreach> element; failure to specify this attribute will result in an error.semantic event being thrown. | ||
| <?xml version="1.0" encoding="UTF-8"?> <ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml"> <eventprocessor> <transition event="connection.alerting"> <accept/> <log expr="'*** CALL ACCEPTED ***'"/> </transition> <transition event="connection.connected"> <!-- NOTE: CHECK THE LOGGER TO SEE THE ARRAY VALUES --> <foreach item="item" object="session.ioprocessors" name="name"> <log expr="'*** IO PROCESSOR ['+name+'] = ' + item + ' ***'"/> </foreach> <exit/> </transition> <transition event="error.*"> <log expr="'ERROR OCCURRED: '+ event$.name"/> <exit/> </transition> </eventprocessor> </ccxml> |
| ANNOTATIONS: EXISTING POSTS |
steve.sax
|
|
|
For those of you who might be interested, here are some examples of the SIP headers that you can utilize to obtain all the information provided by our carriers that you may output using the <foreach> element: ------------------------ session.connections[connid].protocol.sip.headers['from'] ------------------------ ------------------------ session.connections[connid].protocol.sip.headers['via'][0] ------------------------ If would like to check out all information in the SIP headers, you can log each value using the following: <foreach object="session.connections[connid].protocol.sip.headers"> <log expr="'*** name$ = [' + name$ + '] AND index$= [' + item$ + '] ***'"/> </foreach> - Steve |
| login |