Real Examples of Rexsel
The following are examples of Rexsel code. The first is the source code for this site.
Scripts for Rexsel Site
This site uses a Paloose sitemaps to translate XML pages to HTML delivered to the browser. As part of this process there are a set of XSLT
scripts to provide the translation. Rather than define these scripts in XSLT the site uses Rexsel. The sitemap scrap is
<map:match pattern="**.html">
<map:aggregate element="root" label="aggr-content">
<map:part src="cocoon:/headings.xml" element="headings" strip-root="true"/>
<map:part src="cocoon:/menus.xml" element="menus" strip-root="true"/>
<map:part src="cocoon:/newsArticles.xml" element="news-articles" strip-root="true"/>
<map:part src="cocoon:/{1}.xml" element="content" strip-root="true"/>
</map:aggregate>
<map:transform src="context://resources/transforms/page2xhtml.xsl" label="page-transform">
<map:parameter name="page" value="{1}"/>
</map:transform>
<map:transform type="scss" label="scss-content"/>
<map:serialize type="xhtml"/>
</map:match>
Within the match the transform 'page2xhtml.xsl' provides all the necessary to convert the XML into XHTML. The Rexsel source file for this
is 'page2xhtml.rxsl'.
Building the XSL from Rexsel Source
The translation of the Rexsel into the XSL transform files is done only when the site is built. This process takes the Rexsel transform
files (in the example below, from the resources/transforms/rexsel folder in the project) and builds them into the
XSLT scripts in the resources/transforms folder. The translation of Rexsel to XSL is contained in a set of Jakarta
Ant scripts. The relevant part of the build script is
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/Library/Java/Extensions/ant-contrib-0.6.jar"/>
</classpath>
</taskdef>
...
<for param="fileName">
<path>
<fileset dir="${theSourceFolder}/rexsel" includes="*.rxsl"/>
</path>
<sequential>
<exec executable="/usr/local/bin/crexsel" dir="${theSourceFolder}/rexsel" output="report.txt">
<arg value="@{fileName}"/>
<arg value="-e"/> <!-- Generate with errors output at top of XSL file -->
<arg value="-d"/>
<arg value="${theSourceFolder}"/>
</exec>
</sequential>
</for>
This relieves the system from translating the Rexsel "on the fly" for each browser request. CRexsel uses a caching sheme that only compiles
Rexsel source if there has been a change. This can be overidden by the "--force" flag.
Copyright 2024 Hugh Field-Richards. All Rights Reserved.