XRL XML Reference Linker
XRL is an XML pull runtime for combining XML as a recursive series of pulled include evaluations and URI translations. It consists of a
set of accessors that provide a mechanism for flexible creation and serving of static or dynamic content.
It consists of three distinct parts:
mapper which maps an external uri space to an internal uri space. This
allows an abitrary URI space such as a website map to be mapped into resources that
are stored or generated in a different structure.
xrl which provides a convenient template filling and link resolution
operations as well as some convenient low level document manipulation functions. It has the
concept of templates and content.
mapper-export which exports all external links in a links document
to an external location. This is useful for deploying content on a static web server.
It is implemented using the following accessors:
mapper,
xrl and
mapper-export.
active:xrl
XRL is an accessor to perform inclusion of named links, resolution of
named links and substitution of fragments.
Its purpose is to provide a single accessor solution to dynamic
content publishing and solve the problems of recursive template filling,
resolution of named external links and specification of
title/header/footer fields.
Interface
The active URI syntax for xrl is as follows...
active:xrl +links@link_uri +template@xrl:template_link_name [+content@xrl:content_link_name] [+ other arguments ...]
The links and template arguments are mandatory, content is an optional argument described below, other arguments may be
passed on to sub-requests based upon the args specified by a link.
Operation
The template document is the starting point for a recursive inclusion of linked XML resources. The XRL engine traverses the template finding
xrl:includes and evaluating other xrl: operations (described below). The engine uses the xrl:include URI to resolve a link in the links document.
The link provides an internal resource URI which is requested and substitued at the include point.
The processing order is as follows:
- process all <xrl:include> elements in document order
- repeat step one until there are no more <xrl:include>
elements
- resolve all external links @xrl:resolve
- perform all xpath evaluations xrl:include[@xpath] and
xrl:eval[@xpath]
Link Document
The link document has the following structure.
<links basepath="ffcpl:/mybase/">
...
<link>
<name>link_name</name>
<ext>external_uri</ext>
<int>internal_uri</int>
<args>param,links,cookie</args>
</link>
...
</links>
Link Syntax
@basepath is the basepath from which all external URIs will be resolved.
name is the link name that will be exposed as the uri
xrl:link_name.
ext is an external uri which may be
relative to @basepath, if no ext is defined then the link
is purely for internal use.
int is an internal URI to be resolved in the private address space of the module
making the XRL request.
args defines hints as to which arguments to pass to request
for the uri if they are available.
URIs may use the xrl: scheme in which case they will be recursively
evaluated.
Template
The following tags in the namespace
xmlns:xrl="http://1060.org/xrl" will be processed by the XRL engine.
|
tag
|
description
|
|
<xrl:include xmlns:xrl="http://1060.org/xrl" href="uri" />
|
If the uri is xrl: resolve the named link to the internal URI. Then request the
URI with additional args appended, finally substitute content into template.
|
|
<xrl:include xmlns:xrl="http://1060.org/xrl" href="uri"> <some-fragment /> </xrl:include>
|
Same as above but the fragment
inside xrl:include tag will be appended to the internal URI request as the param argument.
|
|
<a xmlns:xrl="http://1060.org/xrl" href="xrl:name" xrl:resolve="href">click</a>
|
Resolve the attribute named in the xrl:resolve, if it is a uri in the xrl: scheme then find the named link and substitute the
external URI into the referenced attribute.
|
|
<td xmlns:xrl="http://1060.org/xrl" style="background:url('[[xrl:image]]')" xrl:resolve="style">hello</td>
|
Same as xrl:resolve above but substitute all [[xrl:****]] in the xrl:resolve attribute with the external URI resolved from
the link.
|
|
<style xmlns:xrl="http://1060.org/xrl" type="text/css" xrl:resolve="text">
body { background: url([[xrl:image]]); }
</style>
|
Same as xrl:resolve above but substitutes the text of current element.
|
|
<xrl:eval xmlns:xrl="http://1060.org/xrl" fallback="'not-found'" xpath="/html/h1/text()" />
|
Evaluate the given xpath expression for text and replace
this tag with the text. If this xpath cannot be evaluated try to evaluate
the optional fallback xpath expression. If this fails substitute a zero length string.
|
|
<xrl:eval xmlns:xrl="http://1060.org/xrl" attribute="href" xpath="/html/h1/text()" />
|
Evaluate the given xpath expression to text and add an attribute to the parent
element with the given attribute name and evaluated text value.
|
|
<xrl:include xmlns:xrl="http://1060.org/xrl" xpath="/html/h1" />
|
Evaluate the given xpath expression to a fragment and
substitute this tag with the fragment. Copy and pastes fragments around a document.
|
|
<xrl:include xmlns:xrl="http://1060.org/xrl" href="xrl:content" />
|
xrl:content is a special link uri to replace this tag with the content argument specified
on the xrl request.
|
Example
See the XML tech tour xrl entry.
XRL Mapper
Mapper is an accessor to take a URI request and map it to a diferent URI based
on the links document syntax specified above.
Interface
active:mapper+operand@request_uri+operator@links_uri
[+ other arguments ...]
Operation
The operand URI of the incoming request is used to match the
external uri of a link in the links document. The interal URI is then determined which
can either be a direct lookup or via a chain of named xrl: links. Any args on the mapper request are passed
on to internal request according to the values specified in the args element. Finally when the internal URI is known
the mapper issues a request for that URI and returns the response.
If an operand path cannot be found the mapper attempts to resolve
the link xrl:404 and passes a parameter doc of the form:
<error> <page>operand_path</page>
</error>
If the link xrl:404 cannot be found an exception is thrown by the
accessor.
If an error occurs in requesting an internal uri the mapper
attempts to resolve the link xrl:500 and passes a parameter doc of
the form:
<error>
<page>operand_path</page>
<ex>netkernel_exception_fragment...</ex>
</error>
If the link xrl:500 cannot be found an exception is thrown by the
accessor.
If an optional <args> element is found in the links doc for
an internal request then the specified args are sent to that request.