Active URIs
Using active URIs
Index > Books > Declarative Development Guide > Reference Library > Developer Guides > Active URIs

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


Introduction

NetKernel schedules URI requests. It can source and sink the conventional URI schemes such as http:, file:. NetKernel processes use the active: URI scheme. Active URI's consist of a type and a series of named URI arguments. The type is matched by an accessor which is responsible for actively generating it's response - an active URI is analogous to method invocation but completely in the URI domain. For more details see here.

Using active URI's indirectly

High level languages such as DPML and XRL schedule processes. They do this by compiling instructions into active URIs which are then scheduled by the Kernel.

Here's an example of a DPML instruction to perform an XSLT transform

<idoc>  <seq>    <instr>
      <type>xslt</type>
      <operand>document.xml</operand>
      <operator>transform.xml</operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Which the DPML runtime compiles to the active URI

active:xslt+operand@document.xml+operator@transform.xsl

An active URI has no special treatment by NetKernel - it is therefore possible to use an active URI anywhere a conventional URI is used. This could be in a module URI rewrite, inside a DPML instruction or an XRL include.

Using active URI's directly

Since we can use an active URI anywhere we could use it as a shorthand inside a DPML instruction. Here's an example that performs a first XSLT transform and then transforms the result with a second XSLT transform...

<idoc>  <seq>    <instr>
      <type>xslt</type>
      <operand>active:xslt+operand@document.xml+operator@transform.xsl</operand>
      <operator>transform2.xml</operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Whilst it is fine to use active URIs in high-level languages, in fact this is precisely how high-level languages compile a process, it is generally not recommended since care should be taken with escaping the active URI's URI arguments.

That said it is often valuable to use active URI's in a module definition. In fact DPML and XRL are initially scheduled by an active URI request using a mapping defined in the module definition.

To see this, create a new module using the new module wizard, make sure you enable DPML support. Your new module will be found in the <install>/modules/ directory. If you examine the module.xml file you will see it contains a URI rewrite rule

<rule>
  <match>(ffcpl:.*\.idoc.*)</match>
  <to>active:dpml+operand@$1</to>
</rule>

This rule rewrites any request for a "ffcpl:" resource which includes ".idoc" to a dpml active URI with the original URI as the operand URI argument. The rewritten URI will be scheduled to the DPML runtime which executes the idoc.

Using active URI with the XML Resource Resolver

Many standard XML technologies (XSLT, XQuery, XInclude, ...) allow the inclusion of other XML resources. All the supplied XML technologies use the underlying NetKernel infrastructure as their resource resolver - this means that requests for active: content will be processed seamlessly. So for example, an XQuery doc("...") source could be an active URI.

Here's an example XQuery with document resource doc("active:dpml...") which is a call to actively execute a dpml source.idoc

<idoc>  <seq>
    <comment> ****************************************** XQuery with active include Returns all items with price &gt;= 10 ****************************************** </comment>
    <instr>
      <type>xquery</type>
      <operator>
        <xquery> &lt;data&gt; { for $item in doc("active:dpml+operand@ffcpl:/trailmaps/ActiveURI/source.idoc")/data/item where $item/price &gt;= 10 return $item } &lt;/data&gt; </xquery>
      </operator>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

Here's source.idoc that's executed by the active:dpml call above...

<idoc>  <seq>
    <comment> ****************************************** A stupid idoc that simply copies a literal to the response. Imagine if this were a real process... ****************************************** </comment>
    <instr>
      <type>copy</type>
      <operand>
        <data>
          <item>
            <price>10</price>
          </item>
          <item>
            <price>8</price>
          </item>
          <item>
            <price>25</price>
          </item>
        </data>
      </operand>
      <target>this:response</target>
    </instr>
  </seq>
</idoc>

You can try the xquery here

© 2003-2005, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.