XRL
XML Resource Linker
Index > Books > Declarative Development Guide > Technology Tour > Runtimes > XRL

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


XML Resource Linker

XRL is a recursive-pull runtime which recursively generates and links XML resources. It is frequently used as a templating language for service-based composition of web-sites - every component of this NetKernel documentation is generated with XRL from the banner menu, the side-bar menu, to the content and footers. For example, here is the service which dynamically generates the 1060 banner ad components.

Componentizing a web site into service based units is highly scaleable, cacheable to fine levels of granularity and produces very highly mantainable web properties.

XRL uses a set of named links to recursively pull together the components of an XML resource. A named link has an internal URI reference and an optional external URI reference. The internal link is a URI reference to a resource which may be either static or dynamically generated. The optional external reference is used by the XRL mapper accessor to initiate an internal process - the ext/int link model enables the decoupling of the public REST interface from the internal address space.

A reference guide and a trailmap worked example of a web-site using XRL are provided as well as an article describing XRLs use in a layered service composition based web-application.

Live Example

Here's is an example of a componentized page generated with xrl.

Header
Menu1
Menu2
#3CDACF
Column
Footer

It is dynamically and recursively built from it's component parts - in this case all but the central body component are static but each could have been dynamically generated. Here is the outer template for this layout. The components are header, menu, column and footer.

The active URI which executed xrl to build this component is shown below...

active:xrl+operator@ffcpl:/xusr/share/doc/docs/xml_technologies/xrl/links.xml+ template@ffcpl:/xusr/share/doc/docs/xml_technologies/xrl/template.xml

the template is the starting point from which xrl recursively executes any xrl:include statements, the links document contains the named links which xrl uses to locate the internal resource to be recursively pulled into the content.

Look at the menu. It is actually two components, an outer menu (light blue) which uses an xrl:include to pull in the inner menu (dark blue)

Menu (containing inner menu)Inner Menu
Menu1
Menu2
Menu2

The central body component is dynamically generated and shows a random color. It is created by including an active URI which executes a simple script, Below is the same component included in a template on it's own.

#F2B956

XRL enables XHTML (or any other XML document) to be componentized. So for example we can restructure the whole layout just by modifying the outer most template.

Header
Menu1
Menu2
Column
#F51A01
Column
Footer

The xrl runtime enables dynamic content to be built and allows every included component to receive user supplied queries, parameters, credentials, session etc. Each component can therefore be a full application in it's own right thus enabling a very powerful portal framework.

Random Colour Component

There are three random color components on this page, each is a different random color since each is independent and dynamically generated as it is included by the XRL engine. XRL sources the active URI from the following link entry.

<link>
  <name>body</name>
  <int>active:beanshell+operator@ffcpl:/xusr/share/doc/docs/xml_technologies/xrl/body.bsh</int>
</link>

The active:beanshell URI executes the following script to create the randomly coloured component...



import org.ten60.netkernel.layer1.representation.*;
import org.ten60.netkernel.xml.representation.*;
import org.ten60.netkernel.xml.xda.*;

import java.util.Random;

/*Fill body with random colour*/
main()
{   //Create a random colour
    String color="#";
    random=new Random();
    r=random.nextInt(255);
    g=random.nextInt(255);
    b=random.nextInt(255);
    if(r<16) color=color+"0";
    color=color+Integer.toHexString(r);
    if(g<16) color=color+"0";
    color=color+Integer.toHexString(g);
    if(b<16) color=color+"0";
    color=color+Integer.toHexString(b);
    color=color.toUpperCase();

    //Source body document
    IXAspect bodyAspect=context.sourceAspect(
            "ffcpl:/xusr/share/doc/docs/xml_technologies/xrl/body.xml",
            IXAspect.class
        );
    DOMXDA body= new DOMXDA(bodyAspect.getReadOnlyDocument());
    //Set style
    style=body.getText("/div/div/@style",true);
    body.setText("/div/center",color);
    color="background-color: "+color+";";
    style=style+color;
    body.setText("/div/div/@style",style);
    
    //Issue response
    response=context.createResponseFrom(new DOMXDAAspect(body));
    response.setExpired();
    context.setResponse(response);

}

© 2003,2004, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.