Functional Programming
Every ECHO script can be thought of as a function; called with a given set of parameters, it produces an output. In the most common case, the inputs are bound to names as parameters in a context, and the output is XML.
Within an ECHO script, every element, whether in the ECHO namespace or otherwise, is either itself a function, or an ECHO modifier/commentary element. The simplest function is one which takes no parameters and produces a literal result.
Example 2. Literal Results
Code
<e:echo xmlns:e='http://namespaces.xmlecho.org/echo">
<h2>Hello</h2>
</e:echo>
produces:
<h2>Hello</h2>
In the above example, an ECHO processor will treat the h2 element as a function which returns the literal results consisting of an element named "h2" and PCDATA contents of "Hello".
Example 3. A Parameterized Script
Code
<e:echo xmlns:e='http://namespaces.xmlecho.org/echo">
<e:paramSet>
<e:param name="yourName">Annie</e:param>
</e:paramSet>
<h2>Hello <e:paramRef refParamName="yourName" /></h2>
</e:echo>
produces:
<h2>Hello Annie</h2>
In this example, the h2 is again producing the literal output element "h2" but performs a function call on the ECHO command, e:paramRef to complete the value of h2's PCDATA contents. The e:param element within the e:paramSet declares that the script will make use of a parameter named "yourName" and gives it a default value.
Since: 1) every ECHO command is an XML element, 2) every content element in an ECHO script is a function, and 3) all ECHO functions produce XML, ECHO commands and non-ECHO elements can be nested and composed into sophisticated processing chains.
The Processing Model
The Echo processor converts a request into a result by applying transformation rules. The transformation rules are applied at the data model level. Before the transformations are applied, the Echo request is parsed into an instance of the Echo XML data model.
Elements in the Echo namespace fall broadly into one of two categories:
1. Content producing elements which are evaluated and replaced with the results of their evaluation.
2. Command modifier and commentary elements which are not evaluated for output, but rather provide for the binding of context parameters to names, declaring Echo function parameter lists, or providing other machine or human accessible metadata.
The modifier/commentary elements are: context, paramSet, documentation and meta.