back to the beginning ... xml recursion language

ROC/NetKernel was originally thought out and developed with XML in mind. Note that it was never (not then, not today) bound to this data exchange format, everything is after all a resource and another format is just a transreption away, but at the time it was the prevailing format. Today JSON is, tomorrow we might lose confidence in braces, ... actually that whole discussion is moot.

Transreption : Lossless transformation of one representation format to another representation format.

If you're a fanboy ... yes, I dropped the word isomorphic from the above definition, that word may mean something to you, it means I like using difficult words to me.

It'll come as no surprise then that there are quite a few NetKernel batteries for slicing and dicing XML.

Battery : Normally some sort of electrochemical cell, here it means an addition that makes usage of a given thing easier, in this case NetKernel.

The single most powerful of these is the XML Recursion Language (XRL). In order to discuss what it does, here's a small XML snippet (that could be the footer of an HTML page) :
<div id="footer">
    <p>All rights reserved. © <span>2013</span> Elephant Bird Consulting BVBA</p>

No, my calendar is not behind. This snippet is a (file) resource that I use over and over again as footer for my webpages. Only, I have to manually update it every year, on every server where I use it. Tedious work and I quite often forget to change it here or there.

Here's the same small XML snippet that solves my problem using XRL :
<div xmlns:xrl="http://netkernel.org/xrl" id="footer">
    <p>All rights reserved. © <span xrl:eval="text">active:widgetCurrentYear</span>
Elephant Bird Consulting BVBA</p>

Now, when I use this template in an active:xrl2 request, it in turn requests active:widgetCurrentYear which is a small component that returns the current year.

That's cool, but it gets even better. Consider this template :
<html xmlns:xrl="http://netkernel.org/xrl">
    <xrl:include identifier="res:/elbeesee/demo/xrl/header"/>
    <xrl:include identifier="res:/elbeesee/demo/xrl/body"/>
    <xrl:include identifier="res:/elbeesee/demo/xrl/footer"/>

Do you see ? When we request active:xrl2 with this template, it will request (and include) the specified resources. Our footer snippet could be the last one. And this is where the recursion comes in. Automagically it will then request active:widgetCurrentYear. And so further, as deep as you care to go !

By the way, it's active:xrl2 because NetKernel 3 contained a quite different version of the tool which is kept available for legacy reasons.

If you want the example, the basic bits (just for the footer, you can no doubt add the complete page with header and body yourself) can be found in my public github archive, you'll need the following modules :
  • urn.com.elbeesee.tool.widget
  • urn.com.elbeesee.demo.xrl
Enjoy !