apache > cocoon

- Home

# Advanced Control Flow - Sitemap

## Sitemap

The Cocoon Sitemap provides two elements to specify interactions with your Flowscripts: flow, and call.

### flow

The `flow` element defines a Flowscript interpreter for a sitemap. The `language` attribute specifies the target programming language. Currently the only supported language is `"javascript"`. Its embedded `script` elements allow you to specify the files that make up the flow for this sitemap. Each `script` element specifies the URI of a script that will be compiled and executed when this Sitemap is created. The `src` attribute specifies the URI of the script.

            <map:flow language="Language">
               <map:script src="URI"/>
            </map:flow>

Example:

            <map:flow language="javascript">
               <map:script src="myApplication.js"/>
            </map:flow>

### call

The `call` element allows you to call a top-level function in your Flowscript or to invoke an existing continuation.

#### function

If the `function` attribute is present, then the Sitemap will invoke a top-level function defined in your Flowscript. The `function` attribute specifies the name of the function. Zero or more nested `parameter` elements may be provided to pass arguments to the function.

            <map:call function="FunctionName">
               <map:parameter name="Name" value="Value"/>*
            </map:call>

Example:

            <map:flow language="javascript">
               <map:script src="myApplication.js"/>
            </map:flow>
            <map:pipelines>
               <map:pipeline>
                  <map:match pattern="index.html">
                     <map:call function="showIndexPage">
                       <map:parameter name="paramName" value="Value"/>
                     </map:call>
                  </map:match>
               </map:pipeline>
            </map:pipelines>

Then in `myApplication.js` you would define a JavaScript function called `showIndexPage()` such as:

            function showIndexPage() {
                var param = cocoon.parameters.paramName;
                sendPage("private/index.html", {param: param});
            }

#### continuation

If the `continuation` attribute is present, then the Sitemap will invoke an existing continuation of your Flowscript. The `continuation` attribute specifies the unique id of the continuation.

            <map:call continuation="Id"/>

Example:

            <map:match pattern="*.form">
              <map:call continuation="{1}"/>
            </map:match>

Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).