Echo

XML Data Processing Language

Bill Lindsey

Contributors Invited

0.3.4

License Terms. Any information furnished in this documentation ("Documentation") is the copyrighted work of Snapbridge Software, Inc.

November 2005

Abstract

This document describes the syntax of Echo, a computer data processing language, and specifies the behavior of Echo language processors in interpreting Echo scripts. The Echo language has an XML syntax, operates on a data model based on the XML Infoset and is designed to work within the REST architecture of the World Wide Web.

This specification documents the core functionality of the language implemented in the currrent version of the XML-Echo/Palomar project. Those constructs in Palomar that might better be treated as extensions are omitted. As Palomar has evolved, new commands have been added while some less than perfect parts of the language have been retained for backwards compatibility with running code.


Table of Contents

Introduction
Motivations
Echo Processor
Security
Echo Programming Model
Functional Programming
The Processing Model
Echo Modifier and Commentary Elements
context
paramSet
documentation
meta
Echo Expressions
boolean expressions
Trim
UserName
Crypt
Substring
SubstringBefore
SubstringAfter
IndexOf
LastIndexOf
StartsWith
EndsWith
Contains
Translate
Millis
Validate
FormatDate
DeformatDate
Hash
Concat
IsMember
QuotedString
IntegerValue
PlusExpr
Multipy Expression
Minus Expression
Divide Expression
User Function Call
Core Echo Command Elements
echo
xslt
eval
quote
noEval
element
standardXMLIn
paramRef
silent
trim
Controlling Script Flow with Logic Elements
Choose
If
wrap
continue
Repository
itemGet
itemEval
itemList
itemPut
itemDelete
createDirectory
chown
chmod
chgrp
writeJar
loadJar
Integration with External Data Sources
rdbRequest
httpGet
httpGetBytes
soap
Stream Based Processing
paginate
xpathFilter
join
intersect
union
sort
count
map
Local File System Interaction
fileGet
filePut
XML Parsing and Serializing
toString
parseString
toStandardOut
parseStandardIn
copyBytes
1. Data Model
Example
References

Introduction

Echo is a computer language for scripting the processing of information; this can be in the form of structured data (databases, flat files, forms, spreadsheets, etc.) or unstructured content (documents, images, etc.). Processing includes actions such as transforming data from one format to another, accessing or storing content, correlating data, and generation of new content. Echo provides a set of commands for specifying these actions in such a way that the processing actions can be composed into information processing applications.

Rather than attempt to redefine the functionality offered by XML processing languages such as XSLT and XQuery, Echo leverages these standards by defining a straightforward, implementation neutral, mechanism for expressing how the inputs and outputs of these processors should be tied together.

Motivations

The Echo language design was informed by these observations:

  • Much of what we do in information processing can be viewed as (or expressed as) transformations of data. ... Programs are filters that, given an input, produce an output.

  • Sophisticated, powerful, information processing systems can be built by composing smaller, special purpose transformation filters in processing chains. ... This is the pipes and filters model.

  • A simple, common data format (XML) that is capable of representing a wide range of rich, complex data structures is ideal for sending through the pipes between filters.

  • XSLT is excellent for defining many (but not all) transformation filters.

  • In order to compose filters into processing chains, a language is necessary to describe that composition.

  • By making that language, itself, representable in our common data format (XML), we can use processing chains to dynamically construct new processing chains, gaining additional expressive power while keeping the number of commands in the language small.

  • By connecting the filters with parse event streams, we gain in performance efficiencies without information loss.

  • An execution environment for the processing chains is needed to provide services such as authorization, connectivity and collection management.

Echo was designed to provide application developers with a natural, direct way to express these pipelined processing chains. Echo contains commands for a rich set of filters and generators. Developers control the composition of the tasks and their order of execution simply by the commands' relative placement within an XML document, with leaf nodes sending their output toward containing elements (commands), which in turn may filter the data and send that output to their parents, upward towards the Echo document's root element and the Echo processor which invoked it.

Echo allows for the implementation of extremely fast and efficient processors:

  • Processors may process large scripts as streams, producing output before having finished loading the entire script, enabling high volume, dynamic content applications .

  • As Echo is a functional language with limited opportunity for side effects, Echo processors can easily inspect scripts to identify results which may be cached for re-use, obtained in advance of their need, or bypassed because they will not be used in a particular case

  • Echo scripts may be compiled to byte-code or machine code

Echo Processor

An Echo Processor is any computer program, that when provided with an Echo script, produces output(s) that conform the rules for processing Echo Commands. Those rules are described in this specification.

An Echo processor transforms instances of an abstract data model (one that is based upon the XML Infoset) to other instances of that data model. Some of those transformations have side effects, such as writing to a file or port, or POSTing to an HTTP location.

An Echo script is a well-formed XML document that specifies how data represented in XML and programs that operate on that data are assembled to produce results. Echo scripts tell the Echo processor:

  • what sources to get data from

  • how to map the data sources into representations to Echo's internal data model

  • what processing and transformations to perform upon the data

  • where to send the resulting representation of processing the data

An Echo Processor operates with a content repository for obtaining and storing text and binary data files as well as XML documents.

All objects (files) in a processor's repository are associated with names. The names are organized into a recursive structure of named collections (or folders) analogous to a computer's file system. An important concept is the "item", which is the association of a name and a version with the folder (its parent property) and a specific XML document, text, or binary file or folder (its contents property).

Example 1. A Simple Echo Script

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo">
    <e:itemGet name="/src/docs/echo/processor.xml" />
</e:echo>

might produce:

<section  xmlns="http://docbook.org/ns/docbook" xml:id="echo-processor">
  <title>Echo Processor</title>
  ...
</section>

In this example, the processing rules in the script require the Echo Processor to return the contents of the document named "/src/docs/echo/processor.xml".

Commands in Echo are expressed syntactically as XML Elements. An Echo processor exhibits specific behaviors for the Elements named here, and has a default behavior for all other elements. Any XML element, therefor, is treated by an Echo processor as a command (or command modifier) in the Echo language, and any well-formed XML document can be treated as an Echo script. The script is rooted at the document element.

Echo Scripts
[1]Echo-script::=content-element
| modifier-element
 

An Echo processor needs to exist in a supporting infrastructure that provides it with:

  • instances of the abstract data model to transform

  • a location to send the result

  • an initial context of name/value bindings (parameters)

  • connections to outside data sources and sinks for reading and writing

  • facilities for parsing XML (and other data formats!) into instances ot the data model

  • facilities for serializing data model instances into XML and other data formats

a Server based Echo processor will also provide a repository for reading and writing named instances, and for associating those instances with metadata such as name, owner, permissions, etc.

Security

Echo does not provide for user authentication, that is expected to be provided by another layer of the environment, such as a web server. An Echo processor does provide, however, information about the authenticated user to allow for Echo scripts to base the authorization.

Security rules for authentication and access control can be applied according to the users' role.

Echo Programming Model

Echo is a functional language structured using the same conventions and rules as XML, itself. This fact has several implications, not least of which is that Echo is naturally highly modular and encourages the developer to build easily maintained code.

But as with any language there are rules, conventions and best practices that you need to follow if you are to get the most of Echo.

The goal of this chapter is to introduce the Echo programming model and suggest some best practices for programming in Echo; later chapters will deal with the specific use of each command.

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

<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

<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.

Elements not in the ECHO namespace

ECHO documents may contain, for evaluation, elements which are in other namespaces. An ECHO processor transforms these elements in one of two manners:

  1. An ECHO processor may be configured to recognize extension elements, and the element is one of those elements. The element name will be bound to some code which will have access to the evaluation context, and which will transform the contents based on the element semantics.

  2. An element which is neither one of the elements identified here, or an extension element which the ECHO processor has been configured to recognize, will be treated as an "element" constructing element as in the section called “element” above, with the name, namespaceName, namespacePrefix and attributes all being provided by this element's start tag

Content Elements
[2]content-element::= Echo-content-element
| non-Echo-element
 
[3]Echo-content-element::= core-element
| repository-command-element
| stream-operation-element
| file-operation-element
| serializing-element
| remote-content-element
Echo Elements ]
[4]non-Echo-element::= any element  

Echo Elements

Echo Elements are in the namespace "http://namespaces.xmlecho.org/echo"

An Echo processor performs the following (conceptual) operations on an Echo script, which results in a transformation of the script into a result.

  1. Construct an instance of the Echo XML data model.

  2. Construct a root evaluation context. An evaluation context binds names to values. The complete set of bindings an Echo processor establishes may reflect particular configuration options, environment or state of the processor, and is not specified here.

  3. Transformation occurs as follows:

    1. a new context is created, including all the bindings of the parent context, and extended by adding any additional bindings obtained from:

      1. any named attributes on the request element. The binding associates the attribute's name with the attribute's value

      2. any named attribute of an Echo element's child "context" element. As above, the binding associates the attribute's name and value

      3. a "value" attribute of a "context" element's "param" child. The binding associates the value of the "param" child element's "name" attribute with the value of the "param" child element's value attribute

      4. the content of a "context" element's "param" child element. If there is no "value" attribute on the "param" element, then the binding associates the value of the "param" child element's "name" attribute with the contents of that "param" child element

    2. The "request" is replaced with the results of transforming (typically) the first child element which is not an Echo documentation element, Echo context, Echo paramSet, or Echo meta element. Different Echo command elements follow different transformation rules in generating the result, and many construct their result through recursively transforming child elements. They may make use of values of the context parameter bindings in deciding what results to produce. Some Echo commands modify the state of an Echo processor during transformation by, for instance, storing a document in the repository.

Echo Modifier and Commentary Elements

Several Echo elements are defined for use by other Echo elements, and do not, by themselves result in any content.

Echo Modifier Elements
[5]modifier-element::= e:context
| e:paramSet
| e:documentation
| e:meta
 
[6]e:context::=( e:param
| e:function ) *
 
[7]e:paramSet::=( e:param
| e:function ) *
 
[8]e:documentation::=any 
[9]e:meta::=any 

context

Echo's context element binds one or more parameter names to values. The bindings can be expressed as either XML Attributes, or as nested children param or function Elements. Parameter values can be strings, elements or functions.

context
[10]e:context::=( e:param
| e:function ) *
 
[11]e:param::=attribute("name=") ,
( 'attribute("value=")' Echo-expression
| content-element | Echo-expression )
 
[12]e:function::=attribute("name=") ,
( 'attribute("value=")' Echo-expression
| content-element | Echo-expression )
 

Context Parameters

All Echo commands use the same technique of extending the evaluation context and in using the evaluation context to obtain named parameters. The parameter named "userID", because it is used for determining user permissions, is special, and can only be bound by the Echo processor's environment.

Parameters are obtained from an Echo element's context. A parameter name may be bound to either a string or an XML document.

In the case of string parameter binding, The string is evaluated as an expression, and substitution may be performed at the time the parameter is obtained from the context.


  <e:toString><e:quote><e:echo xmlns:e="http://namespaces.xmlecho.org/echo">
    <!-- gets the same document 6 times using different techniques for param binding -->
    
    <!-- one way -->
    <e:itemGet name="/test/myDoc.xml" />
    
    <!-- another way -->
    <e:itemGet>
      <e:context name="/test/myDoc.xml" />
    </e:itemGet>
    
    <!-- a third way lets me use non-legal XML attribute name for param name-->
    <e:itemGet>
      <e:context>
        <e:param name="name" value="/test/myDoc.xml"/>
      </e:context>
    </e:itemGet>
    
    <!-- a fourth way value is content of param -->
    <e:itemGet>
      <e:context>
        <e:param name="name">/test/myDoc.xml</e:param>
      </e:context>
    </e:itemGet>

    <!-- parameters are inherited from our ancestor or calling environment -->
    <e:echo>
      <e:context>
        <e:param name="name">/test/myDoc.xml</e:param>
      </e:context>
      <e:itemGet/>
    </e:echo>

    <!-- parameters are evaluated with a very simple expression language-->
    <e:echo>
      <e:context>
        <e:param name="prefix">/test/myDoc</e:param>
        <e:param name="suffix">xml</e:param>
      </e:context>

      <e:itemGet name="{$prefix}.{$suffix}" />
    </e:echo>
  </e:echo>

paramSet

<!-- modifier/commentary element -->
<e:paramSet>
    <!-- param  element --> *
</e:paramSet>

Provides a list of parameter names, and possibly default values, for context parameters which are expected to be referenced when the containing element is evaluated. In the case of xslt, the parameters are made available to the xslt transformation engine.

documentation

Provided to allow developer and/or user documentation to be embedded within ECHO documents. There are no constraints on the contents of this element.

meta

Provided to allow arbitrary meta-data to be embedded within ECHO documents. There are no constraints on the contents of this element.

Echo Expressions

Echo has an expression language for constructing string and Element values. When an Echo context parameter binds a name to a String value, that string value returned is the result of evaluating that string as an Echo Expression.

Expressions operate on and return typed objects. The types are:

  • string
  • number
  • boolean
  • byte stream
  • element
>

Many expressions are functions that require arguments of a specific type. Objects of other types are converted to the required type [ according to some rules to be described ]

Echo Expression
[13]Echo-expression::=String-literal |
| DlcBrace |
| DrcBrace |
| Expression
 
[14]String-literal::=~["{", "}"] 
[15]DlcBrace::="{{" 
[16]DrcBrace::="}}" 
[17]Expression::="{" Whitespace ? Expression * Whitespace ? "}"
| VarReference
| boolean-expression
| TrimFunc
| UserNameFunc
| CryptFunc
| SubstringFunc
| SubstringafterFunc
| SubstringbeforeFunc
| IndexOfFunc
| LastIndexOfFunc
| TranslateFunc
| MillisFunc
| ValidateFunc
| FormatdateFunc
| DatedeformatFunc
| HashFunc
| ConcatFunc
| IsmemberFunc
| QuotedString
| IntegerValue
| PlusExpr
| MultiplyExpr
| MinusExpr
| DivideExpr
| UserDefinedFunc
 
[18]Whitespace::=( " " | "\t" | "\n" | "\r" ) +  
[19]VarReference::="$" Name 
[20]Name::=Letter + ( Digit | Letter | SpecialChar ) *  
[21]Letter::= ["a"-"z", "A"-"Z"]  
[22]Digit::=["0"-"9"] 
[23]SpecialChar::="_" | "-" 

boolean expressions

[24]boolean-expression::= StartsWithFunc
| EndsWithFunc
| ContainsFunc
 

Trim

Trim
[25]TrimFunc::="x" 

describe <title>Trim</title>

UserName

UserName
[26]UserNameFunc::="user-name(" Whitespace? Expression Whitespace? ")" 

describe UserName.

Crypt

Crypt
[27]CryptFunc::="crypt(" Whitespace? Expression Whitespace? ")" 

describe Crypt.

Substring

Substring
[28]SubstringFunc::="substring(" Whitespace? Expression Whitespace? "," Whitespace? Expression ( Whitespace? "," Whitespace? Expression Whitespace? )? ")" 

describe Substring.

SubstringBefore

SubstringBefore
[29]SubstringBeforeFunc::="substring-before(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")"  

describe SubstringBefore.

SubstringAfter

SubstringAfter
[30]SubstringAfterFunc::="substring-after(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")"  

describe SubstringAfter.

IndexOf

IndexOf
[31]IndexOfFunc::="index-of(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")" |
| "x"
 

describe IndexOf.

LastIndexOf

LastIndexOf
[32]LastIndexOfFunc::="last-index-of(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")" 

describe LastIndexOf.

StartsWith

StartsWith
[33]StartsWithFunc::="starts-with(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")" 

describe StartsWith.

EndsWith

EndsWith
[34]EndsWithFunc::="ends-with(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")" 

describe EndsWith.

Contains

Contains
[35]ContainsFunc::="contains(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")" 

describe Contains.

Translate

Translate
[36]TranslateFunc::="translate(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")" 

describe Translate

Millis

Millis
[37]MillisFunc::="millisecs(" Whitespace? ")" 

describe Millis.

Validate

Validate
[38]ValidateFunc::="validate(" Whitespace? Expression Whitespace? ( "," Whitespace? Expression Whitespace? ) ? ")"  

describe Validate.

FormatDate

FormatDate
[39]FormatDateFunc::="format-date(" Whitespace? Expression Whitespace? ( "," Whitespace? Expression Whitespace? ) ? ")"  

describe FormatDate.

DeformatDate

DeformatDateFunc
[40]DeformatDateFunc::="date-deformat(" Whitespace? Expression Whitespace? ( "," Whitespace? Expression Whitespace? ) ? ")"  

describe DeformatDate

Hash

Hash
[41]HashFunc::="hash(" Whitespace? Expression Whitespace? ")"  

describe Hash Function

Concat

Concat
[42]ConcatFunc::="concat(" Whitespace? Expression Whitespace? ( "," Whitespace? Expression Whitespace? ) * ")"  

Concatenates the string values of its arguments.

IsMember

IsMemberFunc
[43]IsMemberFunc::="ismember(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")"  

Returns true if the userID in the first argument is a member of the group identified by the second argument.

QuotedString

QuotedString
[44]QuotedString::=( "'" (~["'"])* "'" ) | ( "\"" (~["\""])* "\"" ) 

A string of characters enclosed in a pair of either single or double quotes.

IntegerValue

IntegerValue
[45]IntegerValue::="x" 

describe IntegerValue.

PlusExpr

PlusExpr
[46]PlusExpr::= "(" Whitespace? Expression Whitespace? "+" Whitespace? Expression Whitespace? ")"  

Adds the number value of the two expressions.

Multipy Expression

MultipyExpr
[47]MultipyExpr::="times(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")"  

returns the product of multiplying the number values of its two arguments.

Minus Expression

MinusExpr
[48]MinusExpr::="minus(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")"  

returns the result of subtracting the number value of the second argument from the number value of the first argument.

Divide Expression

DivideExpr
[49]DivideExpr::="divide(" Whitespace? Expression Whitespace? "," Whitespace? Expression Whitespace? ")"  

Returns the result of dividing the number value of the first argument by the number value of the second argument.

User Function Call

UserFuncCall
[50]UserFuncCall::="^" Name "(" ")"  

Evaluates a user defined function

Core Echo Command Elements

Having established the basic premise of Echo, and the Echo programming model, we can now focus on the commands used in Echo programming. This section contains definitions and examples that illustrate some of the the more commonly used Echo commands.

Core Element
[51]core-element::= e:echo
| e:quote
| e:echo
| e:eval
| e:noEval
| e:xslt
| e:element
| e:standardXMLIn
| e:paramRef
| e:silent
| e:trim
 

echo

Some ECHO commands require a single content producing child element. echo can be used to group multiple elements and/or PCDATA within a single element. It can also be used to group context parameter bindings, parameter declarations and documentation. By convention, echo is commonly the outer-most element in an ECHO script.

echo
[52]e:echo::= modifier-element *
( #PCDATA | content-element ) *
Echo Elements ]

The ECHO processor replaces the echo command in the result by copying any contained PCDATA to the output and recursively processing and transforming any child content elements.

xslt

Transformations are among the most common operations in a pipes and filters programming model, and XSLT is a powerful standard for specifying XML transformations. Echo request elements may invoke XSLT transformations as part of the transformations of their content, and the XSLT stylesheets may, through an XSLT extension element, invoke an Echo processor as part of their transformation.

Echo provides the xslt command to identify the stylesheet and content to transform

xslt
[53]e:xslt::= modifier element * ,
( content-element , content-element )
| content-element
Echo Elements ]

An Echo processor replaces the xslt command with the results of running an XSLT transformation over its last child content element. if there is only one child content element, it is treated as the source content to be transformed, and the stylesheet is located in the repository from the "name" and "path" context bindings. If there are two content elements, the first content element is treated as the xslt stylesheet for the transformation.

The paramSet modifier element, if present, specifies which parameters from the context will be provided to the XSLT transformation engine.

Example 4. xslt transformation

<e:xslt>
  <e:itemGet path="/demo" name="change.xsl"  />	
  <e:itemGet path="/demo" name="foo.xml"  />
</e:xslt>

The Echo processor evaluates the xslt command and replaces it with the results of running an XSLT engine. The input to the transformation will be found in the repository under the name "/demo/foo.xml" and the stylesheet is "/demo/change.xsl"

Example 5. Passing parameters to the XSLT engine

XSLT provides for the execution environment to pass parameters to stylesheets. Echo's xslt makes use of the paramSet element to identify which parameters in the Echo processing context should be made available to the XSLT engine. In this example, the stylesheet uses the parameter named "yourElement" passed from Echo, to determine the name of the output element to substitute for "h2".

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo">
    
    <e:paramSet>
       <e:param name="yourName">Annie</e:param>
       <e:param name="yourElement">div</e:param>
    </e:paramSet> 

    <e:xslt>
       <e:paramSet>
          <e:param name="yourElement" />
       </e:paramSet> 
   
       <e:quote>
          <xsl:stylesheet 
               xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
             <xsl:param name="yourElement" />
             <xsl:template match="h2">
                <xsl:element name="{$yourElement}">
                   <xsl:value-of select="text()"/>
                </xsl:element> 
             </xsl:template>
          </xsl:stylesheet>
       </e:quote>

       <h2>Hello <e:paramRef refParamName="yourName"/></h2>

    </e:xslt>

</e:echo>
        

produces:

<div>Hello Annie</div>

The echo XSLT extension element

Just as Echo can call an XSLT engine, the XSLT engine in an Echo Processor can also call the Echo processor. The XSLT extension extension element, "echo" in the namespace "http://www.blnz.com/namespaces/xx" is implemented in the default XSLT transformation engine. This element allows stylesheets to invoke an Echo processor to generate content during a transformation.

eval

Since ECHO sources and ECHO results are both instances of the data model, the results of evaluating ECHO may itself be treated as ECHO for evaluation. Used in conjunction with the itemGet command, above, this allows us to call ECHO scripts which are stored in the repository from within other ECHO scripts.

eval
[54]e:eval::= modifier element * , content-element Echo Elements ]

Evaluates the contents producing an intermediate result, then evaluates that intermediate result as an ECHO script. Replacement happens in the following steps:

  1. A new context is established as described in step 3.a of the processing model

  2. Transformation is performed on the child element, obtaining an intermediate result.

  3. If there is a second child element, the results of transforming the second child Element is bound to the context parameter name "StandardXMLIn"

  4. Transformation is performed on the root element of the intermediate result to obtain the final replacement.

This has the effect that the result of transforming an ECHO request should itself be treated as a request and transformed

Example 6. Calling ECHO Scripts with eval and itemGet

If we had stored the ECHO script from Example 13, “Revised XSLT with itemGet” in the repository with the name "/demo/run-map.echo", we can call it with our own parameters as follows:

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo">

    <e:paramSet>
    <e:param name="myName">Hector</e:param>
    <e:param name="myElement">h1</e:param>
    </e:paramSet> 
    
    <e:eval yourName="{$myName}" yourElement="{$myElement}">
    <e:itemGet name="/demo/run-map.echo" />
    </e:eval>
    </e:echo>
    

Which produces:

<h1>Hello Hector</h1>

quote

Normal Echo processing can be disabled through the quote command. This allows Elements in the Echo namespace to be copied to the output without interpretation and without attribute expression evaluation.

quote
[55]e:quote::= content-element Echo Elements ]

The Echo processor replaces with the quote command with a literal copy of its single content element with no transformations performed.

Example 7. Using quote

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo" xmlns="">
   <e:quote userHome="jenny" userName="Jennifer">
      <e:xslt xmlns:e="http://namespaces.xmlecho.org/echo">
         <e:itemGet path="/user/{$userHome}" name="jenny.xsl" />
         <h1>hello <e:paramRef refParamName="userName" /></h1>
      </e:xslt>
   </e:quote>
</e:echo>

evaluates to:

<e:xslt xmlns:e="http://namespaces.xmlecho.org/echo">
   <e:itemGet path="/user/{$userHome}" name="jenny.xsl"/>
   <h1>hello <e:paramRef refParamName="userName"/></h1>
</e:xslt>

noEval

As with quote, Echo processing can be disabled through the noEval command. While, like quote, this allows most Echo commands to be copied to the output without interpretation, it differs in that as it copies, it does perform parameter substition through attribute value expression evaluation and through evaluation of Echo's paramRef command.

noEval
[56]e:noEval::= content-element Echo Elements ]

The noEval Echo command element is replaced with a literal copy of its single content element with only parameter substitution transformations performed.

Example 8. Using noEval

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo" xmlns="">
   <e:noEval userHome="jenny" userName="Jennifer">
      <e:xslt xmlns:e="http://namespaces.xmlecho.org/echo">
         <e:itemGet path="/user/{$userHome}" name="jenny.xsl" />
         <h1>hello <e:paramRef refParamName="userName" /></h1>
      </e:xslt>
   </e:noEval>
</e:echo>

evaluates to:

<e:xslt xmlns:e="http://namespaces.xmlecho.org/echo">
   <e:itemGet path="/user/jenny" name="jenny.xsl"/>
   <h1>hello Jennifer</h1>
</e:xslt>

element

The element command produces an XML element with a specified name in the output.

element
[57]e:element::= modifier-element *
( #PCDATA | content-element ) *
Echo Elements ]

Table 1. element parameters

nametyperequired?description
elementNamestring*the local part of a namespace qualified element name
elementNS  the namespace of the element's name
elementNSPrefix  the prefix for the element's namespace qualified name

Replaced with an element with a name constructed from "elementName" for the localName, and namespace from "elementNS" and a namespace map which assocates the namespace with the prefix in elementNSPrefix.

The contents of the generated element are replaced in the result by copying any PCDATA to the output and recursively processing and transforming any content elements.

standardXMLIn

An Echo processor may provide an XML representation of inputs to an Echo process invocation through this mechanism. This is a convenient method of passing HTTP GET and/or POST parameters to Echo scripts which service the request.

standardXMLIn
[58]e:standardXMLIn::= empty Echo Elements ]

Replaced with the element bound to the context parameter "StandardXMLIn"

Example 9. standardXMLIn

In addition to binding individual parameters in an Echo processor's base context, Information Server's standard HTTP interface also takes all GET or POST parameters and constructs from them an XML document with the root element named "formXML". That document is available through the standardXMLIn command. Given the Echo following Echo script stored in the repository at: "/demo/stdin-example.echo":

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo" xmlns="">
    <e:standardXMLIn />
</e:echo>

and called with a HTTP GET through a URI that looks something like:http://localhost:9090/fdx/fsget/demo/stdin-example.echo?yourName=jane&yourElement=baz, we would expect to get:

<formXML>
    <parm name="yourName">
        <value>Jane</value>
    </parm>
    <parm name="yourElement">
        <value>baz</value>
    </parm>
</formXML>

Example 10. using standardXMLIn with eval

The command, eval, is also able to bind, from its second child element, an XML document for later use by standardXMLIn. Calling the above Echo script through the eval in another script is shown here:

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo">
    <e:eval>
        <e:itemGet name="/demo/stdin-example.echo" />
        <foo><bar>...</bar></foo>
    <e:eval>
<e:echo>

will result in:

<foo><bar>...</bar></foo>

paramRef

Content can be dynamically generated from values bound to context parameters. The paramRef command places the value of a named parameter into the output.

paramRef
[59]e:paramRef::= modifier-element * Echo Elements ]

Table 2. paramRef Parameters

nametyperequired?description
refParamNamestring*The name of the context parameter from which content is obtained

Replaced with the value bound to the context parameter whose name matches the value bound to "refParamName", either a string or XML document.

Example 11. Parameter scoping

We demonstrate here the use of paramRef to place the value of a parameter into the output of the ECHO processor. Note that the scope of the binding is limited to the containing element. We also show one parameter (p2) being defined in terms of another (p1).

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo" xmlns="">
    <div>
        <e:echo p1="one">
            <p>p1: "<e:paramRef refParamName="p1" />"</p>
                <e:echo p1="two">
                   <p>p1: "<e:paramRef refParamName="p1" />"</p>
                   <e:echo p2="--{$p1}--">
                      <p>p1: "<e:paramRef refParamName="p1" />",
                         p2: "<e:paramRef refParamName="p2" />"</p>
                   </e:echo> 
                </e:echo>
            <p>p1: "<e:paramRef refParamName="p1" />"</p>
        </e:echo>
    </div>
</e:echo>

results in:

<div>
    <p>p1: "one"</p>
    <p>p1: "two"</p>
    <p>p1: "two",
       p2: "--two--"</p>
    <p>p1: "one"</p>
</div>

silent

Silent evaluates its contents in exactly the same manner as echo, but returns no transformed results. This can be useful in evaluating some ECHO code for its side effects, such as inserting a document with itemPut, while discarding the output.

silent
[60]e:silent::= modifier-element *
( #PCDATA | content-element ) *
Echo Elements ]

Replaced by an empty string.

trim

Trim evaluates its contents in exactly the same manner as echo, but removes leading and trailing whitespace.

trim
[61]e:trim::= modifier-element *
( #PCDATA | content-element ) *
Echo Elements ]

Controlling Script Flow with Logic Elements

Echo has commands which allow the application developer to test conditions and control which comands are executed based on the results of those tests.

Flow Control
[62]flow-logic-element::= e:choose
| e:if
| e:wrap
| e:continue
 

Choose

choose
[63]e:choose::= modifier element * , content-element , e:when + , e:otherwise ?  
[64]e:when::= modifier element * , content-element  
[65]e:otherwise::= modifier element * , content-element  

[ describe ]

If

if
[66]e:if::= modifier element * , content-element  

[ describe ]

wrap

Evaluates its first child content element with the un-evaluated second child element bound to the context parameter "continuation".

wrap
[67]e:wrap::= modifier-element * , content-element , content-element Echo Elements ]

wrap is replaced by the results of evaluating it's first child content producing element. Binds the second element to the special context parameter, "continuation", then evaluates the first.

During it's evaluation, the first element may request the second element's evaluation along with any new bindings of context parameters by invoking the continue element

Example 12. Using wrap

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo">

  <e:wrap>

    <!-- item 1 some ECHO to evaluate -->
    <e:xslt path="/homework/testje" name="map.xsl"/>    
      <e:continue/>
    </e:xslt>


    <!-- item 2 some ECHO to evaluate whenever we find "continue" in item 1 -->
    <e:xslt path="/homework/testje" name="fed-merge.xsl"/>     
      <e:itemEval path="/homework/testje" name="federate.echo"/>
    </e:xslt>
        
  </e:wrap>       

</e:echo>

continue

continue
[68]e:continue::= modifier-element * Echo Elements ]

Replaced by the results of evaluating the Echo command element bound to the special parameter "continuation".

continue can be used to evaluate an Echo procedure from within another procedure. Typically, the "continuation" procedure is created by the Echo command element, wrap.

Repository

An Echo processor may be able to store and manage repositories of text files, binary data files and XML documents.

All XML documents and files in a repository are associated with names. The names are organized into a recursive structure of named collections (or folders) analogous to a computer's file system. An important concept is the "item", which is the association of a name and a version with the folder (its parent property) and a specific XML document, text, or binary file or folder (its contents property).

An Echo processor's repository may also contain a native XML database. Queries may return a collection of nodes across a set of documents.

Some Echo request elements obtain content from or metadata about items in an Echo processor's content repository

Repository Command Elements
[69]repository-command-element::= e:itemGet
e:itemEval
| e:itemList
| e:itemDelete
| e:itemPut
| e:createDirectory
| e:chown
| e:chgrp
| e:chmod
| e:writeJar
| e:writeJar
 

itemGet

Rather than including the all the content, stylesheets, and ECHO scripts in-line, we can share and re-use components by storing them as items in the repository. This enhances modularity. To obtain the content of an XML document from the ECHO processor's repository, use the itemGet command.

itemGet
[70]e:itemGet::= modifier-element * Echo Elements ]

Table 3. itemGet Parameters

nametyperequired?description
namestring the name of the repository item
pathstring  the path to the repository item
itemIDstring the repository's unique identifier for the item

Replaced by an XML document identified by name and path or by itemID from the XML content repository managed by the ECHO processor.

Example 13. Revised XSLT with itemGet

If we had stored the stylesheet from the Example 5, “Passing parameters to the XSLT engine”, above, in the repository with the name "/demo/map-h2.xsl", we can re-write our ECHO as follows:

<e:echo xmlns:e="http://namespaces.xmlecho.org/echo">

    <e:paramSet>
       <e:param name="yourName">Annie</e:param>
       <e:param name="yourElement">div</e:param>
    </e:paramSet> 

    <e:xslt>
        <e:paramSet>
           <e:param name="yourElement" />
        </e:paramSet> 
   
        <e:itemGet name="/demo/map-h2.xsl" />
        <h2>Hello <e:paramRef refParamName="yourName"/></h2>

    </e:xslt>

</e:echo>
        

Identifying Repository Items

In commands dealing with repository contents, we use some common parameters for identifying which item (or items) we are selecting. These parameters are name, path and itemID.

Every item (and each version of an item) in a repository is associated with a unique identifier. Use the parameter itemID to access a repository item by way of that unique ID.

Usually, it is preferable to access the item by name instead of by ID. That way you are ensured of getting the latest version of the item. The ECHO processor uses two parameters to obtain the fully qualified name of an item in the repository: path + name. The path parameter allows your code to implement the notion of a "current working directory" with repository item names being resolved relative to that path. If the name begins with a '/' character, the name is taken to be absolute, and the path component is ignored. Otherwise, path and name are concatenated together then normalized to produce a fully qualified name.

itemEval

Echo scripts often make use of other scripts in the Echo processor's repository by getting, then evaluating the script. One way to accomplish this is to place an itemGet element inside an evalelement.

<e:eval xmlns:e="http://namespaces.xmlecho.org/echo"><e:itemGet name="/test/foo.echo"/></e:eval>

A shorter way to accomplish this same effect is with itemEval, which performs both actions in a single command

<e:itemEval xmlns:e="http://namespaces.xmlecho.org/echo" name="/test/foo.echo"/>

itemEval
[71]e:itemEval::= modifier-element * Echo Elements ]

Table 4. itemEval Parameters

nametyperequired?description
namestring the name of the repository item
pathstring  the path to the repository item
itemIDstring the repository's unique identifier for the item

Replaced by the results of processing the XML document identified by name and path or by itemID from the XML content repository as an Echo script.

itemList

We use itemList to get information about items in the ECHO processor's repository, and in the case of Folders, a listing of their contents.

itemList
[72]e:itemList::= modifier-element * Echo Elements ]

Table 5. itemList parameters

nametyperequired?description
depthint Number of levels of subdirectiories to recursively list
ownerIDstring only list items owned by the given ownerID
createdSincestring (date) only list items with a creation time after this value
createdBeforestring (date) only list items with a creation time earlier than this value
updatedSincestring (date) only list items with a update time after this value
updatedBeforestring (dated) only list items with an update time earlier than this value
nameRegexstring a regular expression. Only items whose name are matched by the regular expression are returned
dirPathRegexstring a regular expression. Only items whose name path are matched by the regular expression are returned
namestring the name of the repository item
pathstring  the path to the item
itemIDstring the repository's unique identifier for the item

Example 14. itemList

We show, here, the result of calling itemList on a folder item containing three content items:

<e:itemList name="/demo/examples" />

returns:

<folder id="11698" name="examples" revision="1" 
        current="yes" mimeType="FOLDER" docID="" 
        parent="762" status="1" ownerID="1" owningGroupID="1" 
        createTime="2003-10-26 08:34:58" lastUpdated="2003-10-26 08:34:58" 
        permissions="279" dirPath="/demo" read="true" write="true" exe="true">
    <doc id="9716" name="example3.echo" revision="1" current="yes" 
         mimeType="application/xml" docID="6755" parent="11698" 
         status="3" ownerID="1" owningGroupID="1" 
         createTime="2003-10-22 16:16:01" lastUpdated="2003-10-22 16:16:01" 
         permissions="279" dirPath="/demo/examples" 
         read="true" write="true" exe="true"/>
    <binary id="11699" name="ad_info.gif" revision="1" 
            current="yes" mimeType="image/gif" docID="" parent="11698" 
            status="1" ownerID="1" owningGroupID=