| Name: | DPML | | Description: | The active:dpml service is the DPML runtime engine which executes DPML scripts | | Id: | DPMLRuntime | | Category: | accessor |
Identifier SyntaxDPML is an accessor using Active URI syntax with the following base identifiers:
and the following arguments: (for more details on argument passing details see here)
| Argument | Rules | Typing | Description | | operator | Mandatory | Representation (java.lang.Object) | The DPML program script to be executed | | response | Optional | Representation (java.lang.Object) | The internal assignment returned as the response from the script execution | | varargs
[varargs]
| Any quantity | Representation (java.lang.Object) | Varargs allows an arbitrary number of additional unspecified arguments.
|
Request VerbsThe following
verbs are supported:
ResponseThe response representation of this accessor for SOURCE requests is unknown. This accessor throws no documented exceptions.Import RequirementsTo use DPML accessor you must import the module
urn:org:netkernel:lang:dpml:
<import> <uri>urn:org:netkernel:lang:dpml</uri> </import>
|
The Declarative-Request Process Markup Language (DPML), is a simple,
lightweight language. With DPML you can write programs that directly request
information resources and leverage various resource models without knowledge
of low-level APIs and objects.
SOURCE
When a request with the SOURCE verb is issued to active:dpml
the DPML script specified in the required operand argument is
brought into the DPML language runtime environment.
A request is then made for the assignment made to response
(unless another assignment is specified by the optional response argument).
If the root element of the DPML script is a closure, then the closure
with the specified assignment is evaluated and its response is returned
as the response to the SOURCE request.
If the root element of the DPML script is a sequence, then the
child elements of a sequence are evaluated in order.
If during this evaluation an assignment is made to response, this is returned,
if no assignment is made to response the null is returned.
Arguments may be passed into the DPML script by including one or more
optional additional arguments.
These additional argument are available to the script through the
arg: URI scheme.
Example - Closure
This DPML script uses a closure as the root element and includes
two closures with their assignments.
By default, the closure with the assignment to response
is evaluated and returned.
<closure>
<closure assignment="output">
<literal type="string">Output</literal>
</closure>
<closure assignment="response">
<literal type="string">Response</literal>
</closure>
</closure>
The following code will cause the variable answer to
contain the text value Response:
request = context.createRequest("active:dpml");
request.addArgument("operand", "res:/scripts/closures.dpml")
answer = context.issueRequest(request);While the following code will cause the variable answer to
contain the text value Output:
request = context.createRequest("active:dpml");
request.addArgument("operand", "res:/scripts/closures.dpml")
request.addArgumentByValue("response", "output")
answer = context.issueRequest(request);Example - Sequence
This DPML script uses a sequence as the root element which includes two requests.
Both make an assignment to response.
The requests are evaluated in document order and
only the final assignment to response
is made available to the external client.
<sequence>
<request assignment="response">
<identifier>res:/first.txt</identifier>
</request>
<request assignment="response">
<identifier>res:/second.txt</identifier>
</request>
</sequence>
When the following code is executed, the variable answer
will be set to the evaluation of the second request which provides
contents of the resource res:/second.txt.
request = context.createRequest("active:dpml");
request.addArgument("operand", "res:/scripts/sequence.dpml")
answer = context.issueRequest(request);Example - Arguments
This DPML script contains a request for a resource identified by the
value of an optional argument named resource.
<sequence>
<request assignment="response">
<identifier>arg:resource</identifier>
</request>
</sequence>
When this is executed by the DPML runtime using the following code:
request = context.createRequest("active:dpml");
request.addArgument("operand", "res:/scripts/program2.dpml")
request.addArgument("resource", "res:/greeting.txt")
answer = context.issueRequest(request);The variable answer will be set to the
contents of the resource identified by the resource argument.
SINK
When a request with the SINK verb is issued to active:dpml
the DPML script specified in the required operand argument is
brought into the DPML language runtime environment.
The processing is identical to the processing for the
SOURCE verb except that the value of arg:verb is set
to the text value SINK.
The representation passed in this request as the primary argument
is available as arg:primary.
NEW
When a request with the NEW verb is issued to active:dpml
the DPML script specified in the required operand argument is
brought into the DPML language runtime environment.
The processing is identical to the processing for the
SOURCE verb except that the value of arg:verb is set
to the text value NEW.
EXISTS
When a request with the EXISTS verb is issued to active:dpml
the DPML script specified in the required operand argument is
brought into the DPML language runtime environment.
The processing is identical to the processing for the
SOURCE verb except that the value of arg:verb is set
to the text value EXISTS.
DELETE
When a request with the DELETE verb is issued to active:dpml
the DPML script specified in the required operand argument is
brought into the DPML language runtime environment.
The processing is identical to the processing for the
SOURCE verb except that the value of arg:verb is set
to the text value DELETE.