Hello World is not enough
To start let's consider the most simple process possible, let's reproduce a static resource. In this
case a simple 'Hello World' XHTML page:
<html> <body> <p>It's traditional at this point to say</p> <h1>Hello World</h1> <br /> <br /> <i>It will get more interesting we promise...</i> </body> </html>
You can view this page here .
Given how incredibly dull this page is you would be justified in thinking that it was not the result
of a DPML process. However it was actually produced by this DPML instruction document:
<idoc> <comment>
***************************
DPML Tutorial - App1
Copy, Response
***************************
</comment> <seq> <instr> <type>copy</type> <operand>ffcpl:/hello.xml</operand> <target>this:response</target> </instr> <instr> <type>cast</type> <operand>this:response</operand> <operator> <cast> <mimetype>text/html</mimetype> </cast> </operator> <target>this:response</target> </instr> </seq> </idoc>
"You're blinding me with angle brackets! Someone said shallow end! What does it all mean?"
To start with lets ignore <idoc>, <comment> and <seq> but remember that in DPML comments are always first class data. We'll come
back to comments later on in the tutorial.
For the moment lets concentrate on the important part the first <instr> This is the start of a DPML
instruction. Within this first instruction there are three elements <type>, <operand> and <target> .
<type> | contains the type of the instruction. |
<operand> | has the URI of the resource that will be processed by this instruction, in this case it's ffcpl:/hello.xml document located
in the system root directory. Don't worry about the ffcpl: URI scheme, it is used to identify a resource in the virtual filesystem, for the moment just
pretend that this is file: , we'll explain more about the filesystem and system URI schemes later. |
<target> | is the URI to which the result will be assigned, in
this case it is the special target this:response . |
So the simple summary of this first instruction is to copy the resource identified by the operand to the resource specified by the target.
Which specifically means that this idoc copies ffcpl:/hello.xml to this:response . Where this:response is the URI of
the response which is always returned by a DPML instruction document.
Note that your system is configured so that the request came in to the system on the HTTP transport
and so this:response is served back as an HTTP response, hence you see the resulting document in your browser. If the application
were invoked from another transport then this:response would be returned as appropriate. We'll cover the context for
this:response in more depth later.
You are a...
An instruction type is actually a name assigned to a Universal Resource Accessor. An Accessor is a gateway to a resource.
It is complementary to the Universal Resource Identifier (URI), most
familiar to us in the form of URL's to web resources.
In the first example above the Accessor we are using is the
copy accessor, it could equally be called the identity accessor since it produces
an exact copy of the resource referenced by the operand. As we progress we will show examples of other URAs and show
how URAs can be created and incorporated for use within DPML.
In DPML all resources are referenced by URI's and accessed through Universal Resource Accessors.
The DPML implementation on the 1060 NetKernel relies on the Kernel to take care of all
resource management for us. For example, in this first application the request for ffcpl:/hello.xml is handled by the kernel.
The kernel in combination with a core set of URA's takes care of URI resolving, XML parsing and
resource caching for any resource request. By accessing resources through the kernel we never need to think about
XML parsing and we can be certain that the kernel will maintain a pre-parsed cached resource whenever it can.
As we will see, the URI and URA model is a natural and extremely powerful abstraction when processing XML resources.
Type Cast
We need to briefly mention the final instruction. This instruction cast's this:response to a MIME type
of text/html We will explain more about the construction of this instruction, types and type casting later. For the moment
it is enough to say that this instruction ensures that the result of this idoc is treated as HTML by the HTTP transport.
|