CCXML 1.0 Development Guide Home  |  Frameset Home


<foreach>  element

Voxeo Extension Element
The <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.


usage
<foreach cond="(ECMAScript Expression)" item="NMTOKEN" name="(variable name)" object="(ECMAScript Expression)">


attributes
cond Data Type: (ECMAScript Expression) Default: none - attribute is required
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: NMTOKEN Default: Required
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.
name Data Type: (variable name) Default: Required
The name attribute defines the name of the index that is to br refenced, (in this case, the connectionid).
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.




parents
none


children
none


code samples
<1.0 foreach -item-object-name> sample
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml">

<eventprocessor>

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

  <transition event="connection.connected" name="evt">
  <!-- 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.*" name="evt">
  <log expr="'ERROR OCCURRED: '+ evt.name"/>
  <exit/>
  </transition>

</eventprocessor>

</ccxml>



additional links
none


  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login



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