Servicereq processing model
From Friend2Friend Wiki
The <servicereq> processing model is the heart of how F2F code is interpreted. XML containing requests (usually <f2f:servicereq> elements) is iteratively processed as follows.
Contents |
Overview
| 1) | If it has an active request Goto (2), Else Goto (3) |
| 2) | The active request is processed and its output replaces the request element, then Goto (1) |
| 3) | Processing stops. A 'term' message sends the XML contents back to their parent. |
Active Request
The definition of active is a rather daunting looking 6 lines of XPath, but it amounts to picking the first live request, in document order, where live is defined as follows:
Live Request
A live request is one that is due to be processed sooner or later. An element is live if:
| a) | It is a <f2f:servicereq>, <f2f:hookreq> or <f2f:scriptreq> |
| b) | It does not have an id attribute |
| c) | It does not have an ancestor with an f2f:escaped or f2f:sendescaped attribute |
| d) | It does not have an f2f:escaped or an f2f:sendescaped attribute equal to "*" |
| e) | It does not have a descendant which is live |
This may seem complex, but it is a variant on a simple idea :"document order, but evaluate nested <servicereqs> first". The exceptions are the optional attributes:
| 'id' | (=don't process this node, it's already been processed, and is awaiting a reply), |
| 'f2f:escaped="!"' or 'f2f:escaped="N!"' | (=don't process this node's children) [N=integer] |
| 'f2f:escaped="*"' or 'f2f:sendescaped="*"' or | (=don't process this node or its children) |
Request Processing
The only compulsory attribute of a request is its function, which determines how it is processed:- If it corresponds to a core service, it is handled by F2F Hard Code, otherwise it is processed using the corresponding XSL transform. Requests may be modified by optional extra attributes referred to as processing directives.
