Chapter 6. DPML

Declarative-Request Process Markup Language (DPML) is a heavyweight name for a simple, lightweight language. It has a simple syntax to do one thing extremely well, resource request handling.

Glue

You’re probably wondering why you should learn yet another language, and one with a limited use, too. The chance you heard of DPML before you started with NetKernel is zero.

Remember the hello.dpml program from FirstModule?

<?xml version="1.0" encoding="UTF-8"?>
<sequence>
  <request assignment="response">
    <identifier>active:freemarker</identifier>
    <argument name="operator">
      <literal type="string">Input value: ${value}</literal>
    </argument>
    <argument name="value">arg:value</argument>
  </request>
  <log>
    <message>
     <literal type="string">DPML example running with input %1</literal>
    </message>
    <param>arg:value</param>
  </log>
</sequence>

The hello.groovy equivalent looks like this:

import org.netkernel.layer0.nkf.NKFException; import org.netkernel.layer0.nkf.INKFRequestReadOnly; value = context.source("arg:value", String.class); subrequest_url = "active:freemarker"; subrequest = context.createRequest(subrequest_url); subrequest.setVerb(INKFRequestReadOnly.VERB_SOURCE); subrequest.addArgumentByValue("operator",'Input value: ${value}'); subrequest.addArgumentByValue("value",value); subrequest.setRepresentationClass(String.class); resultString = context.issueRequest(subrequest); logString = context.formatRaw('DPML example running with input %1',value); context.logRaw(context.LEVEL_INFO,logString); ...

Get Resource-Oriented Computing with NetKernel now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.