arc:first

Version 24.2.9039


arc:first


Use the arc:first keyword to execute a section of a script for only the first iteration of an arc:call or arc:enum keyword. It is a convenient way to generate headings or to inspect the first item of a feed before going through the rest of the feed.

During the first iteration, the arc:first body executes before any other code within the arc:call or arc:enum, regardless of where the arc:first is located in the arc:call or arc:enum body. Therefore, CData recommends that you place arc:first at the top of the arc:call or arc:enum body.

If the scope has no items, neither arc:first nor arc:last is executed.

Parameters

None

Control Attributes

None

Example

Create an HTML table from a feed where each item is represented as a row:

<arc:call op="listCustomers">
  <arc:first>
    <table>
    <thead>
      <arc:enum item="customer">
        <td>[_attr]</td>
      </arc:enum>
    </thead>
  </arc:first>
    <tr>
      <arc:enum item="customer">
        <td>[_value]</td>
      </arc:enum>
    </tr>
  <arc:last>
    </table>
  </arc:last>
</arc:call>

See Also

  • arc:last: Execute a code block only for the last iteration.