#####INCLUDE z.upperside.html
Every script field in MockMotor - match scripts, payload scripts, header scripts, account selectors, delay expressions, account-update scripts - sees the same set of variable namespaces, in either JavaScript (input.foo) or XQuery ($input//*:foo) form depending on which language the field is written in. A Simplified shorthand (see below) also lets you drop the namespace prefix entirely in most of these fields.
| Namespace | JS form | XQuery form | What's in it |
|---|---|---|---|
input / request | input.header.account.id | $input//*:AccountId/text() | The parsed request payload (JSON or XML). request is a plain alias for input. |
http | http.headers['X-TxId'], http.parameters.id | $http//*:header[@name='X-TxId'] | method, relativeURI, queryString (raw, not URL-decoded), parameters (parsed/decoded; a repeated parameter becomes multiple values), headers. |
rest | rest.method, rest.parameters.userId | $rest//*:parameter[@name='userId']/text() | The HTTP method and the relative-URI's own {param} placeholders (see below) - a narrower, path-focused counterpart to http. |
account / accounts | account.level, accounts[0].id | $account/*:level/text() | The mock account(s) selected by the reaction's Account Selection script - see Mock Accounts. account/$account is one match (chosen arbitrarily if several matched - account/$account is null/empty-sequence if none did); accounts/$accounts is the full set. A property with multiple values becomes a JS array / repeated XML elements. |
mockmeta | mockmeta.random, mockmeta.reaction.calls | $mockmeta/*:random/text() | random (0-1), randomUUID, epochMs (milliseconds since epoch), and .calls under environment/service/reaction (running call counts for each). |
output / response | output.status | $output//*:status | The response computed so far. Not available in match scripts or the account selector (the response doesn't exist yet at that point) - only in delay expressions, custom headers, and account-update scripts, which run after the payload. |
JWT / JSON | JWT.verify(...) | - | Built-in helper modules - see CORS & Auth Basics and Script Library. JavaScript-only; not available to XQuery fields. |
A reaction's Relative URI match field can contain named placeholders: /user/{userId}/statement/{statementId} binds userId/statementId as top-level variables (and under rest). A catch-all form, /acc/{alltherest:.*}, captures everything after the prefix into one variable.
In any field that supports scripting (matching, account selection, payload, status, delay), you don't have to spell out the full account/rest/http path - the property name alone resolves automatically:
| Variable type | Full form | Simplified |
|---|---|---|
| HTTP parameter (JS) | http.parameters.userId | userId |
| REST path parameter (JS) | rest.parameters.mode | mode |
| Account property (JS) | account.streetNumber | streetNumber |
| HTTP parameter (XQuery) | $http//*:parameter[@name='userId']/text() | $userId |
| REST path parameter (XQuery) | $rest//*:parameter[@name='mode']/text() | $mode |
| Account property (XQuery) | $account/*:streetNumber/text() | $streetNumber |
For example, a payload script can write "userId": userId instead of "userId": account.userId, or {$streetNumber} instead of {$account/streetNumber/text()}.
If a name exists in more than one namespace, the priority is REST parameters > HTTP parameters > account properties. mockmeta, input/request, and output/response are never simplified - always spell those out.
| What to check | JavaScript | XQuery |
|---|---|---|
| Property exists in the payload | input.user.birthDate | $input//*:birthDate |
| Property matches a value | input.user.id=='120000' | $input//*:id='120000' |
| Property via JSONPath (request only) | $..id | - |
| Header matches a value | http.headers['X-TxId']=='8' | $input//*:header[@name='X-TxId']/text()='8' |
| Mock account property | account.level=='BASIC' | $account//*:level/text()='BASIC' |
| HTTP query parameter | http.parameters.id=='0' | $http//*:parameter[@name='id']/text()='0' |
| HTTP method (either of two) | rest.method=='GET' || rest.method=='XGET' | $rest//*:method/text()=('GET','XGET') |
| Random / intermittent response | mockmeta.random < 0.1 | $mockmeta/random < 0.1 |