Once the content data is captured (via XForms) as XML instance documents, it needs to be rendered to site visitors in a human-readable format (typically HTML). This transformation can be done at request time (by converting the XML to HTML on the fly) or at authoring time, via the use of 'renditioning templates'.
Alfresco provides two renditioning engine implementations, one which uses XSL templates, and the other freemarker. In both cases, the form instance data (XML) is passed to the template to be rendered. The following are simple examples of how a simple XML document can be processed by both FreeMarker and XSL.
Resulting HTML output rendition (using either FreeMarker or XSL):
Variables and Functions exposed to Rendering Engine
Alfresco makes a set of helper variables and functions available within both FreeMarker and XSL rendering engine templates. These allow the author of a rendering engine template to perform conditional logic, extract content from the repository.
Here's a list of the variables and functions provided:
avm_sandbox_url: A variable that provides the URL to the root of the current sandbox. For example: http://www-alfresco2--admin.avm.alfresco.org:8180
form_instance_data_file_name: A variable that provides the name of the file containing the form instance data being used.
rendition_file_name: A variable provides the file name of the rendition being produced.
parent_path: A variable that provides the parent_path of the rendition being produced. This is an AVM path of the form: alfresco2-admin-main:/appBase/avm_webapps.
parseXMLDocument(String virtualPath): A function returning the root element of the XML file at the given virtualPath. A 'virtual path' is virtualized path within the AVM repository. The most recent version within the repository is assumed (i.e.: version -1).
parseXMLDocuments(String formName, String virtualPath): A function returning an iterator over the root elements of the XML documents at directory given by virtualPath; this interator only contains those form instance data files generated by formName. In FreeMarker, the return value of this function is a list. In XSL, the return value is a node-set. In either case, the attribute alf:file_name is set on each element; this contains the name of the file that was parsed.
In Freemarker, all variables and functions are in a hash called alf. For example, to access the value of the parent_path variable, use the FreeMarker expression:
In XSL, all variables are in the namespace alf. Thus, to access the value of the parent_path, use the XSL expression:
Both Freemarker and XSL support including one template (or stylesheet) from another using the #include directive and xsl:include tag respectively. The template to include can be either a path within the virtualized webapp the form is configured for, or secondarily the name of the file to include in the form's folder within the Web Forms space in the Data Dictionary.