XSLTForms/XSLTForms only Extensions

< XSLTForms


Configuration options affecting the XSLTForms transformation are taken from the sources below, where the value for each option is the one found first:

  1. externally-defined XSLT Parameters,
  2. config_LANG.xsl file,
  3. Processing-Instructions(PIs).

XSLT ParamsEdit

Under the xmlns="http://www.w3.org/1999/XSL/Transform" the following xsl-params are accepted:

  • baseuri: If unspecified, defaults to the base-name of of the xsltforms.xsl href.
  • xsltforms_caller:
  • xsltforms_config: A nodeset having as child the configuration <properties> element that are to be copied on the result xforms-page. Defaults to the ones specified in config.xsl file.
  • xsltforms_debug: 'yes' or anything else. If unspecified, assumed no-debug.
  • xsltforms_lang: The suffix to use when selecting the language file config_<SUFFIX>.xsl which specifies messages, calendar and other localizations/I18Ns.

Note that xsltforms_config, xsltforms_debug, xsltforms_lang params are further applied to any subsequent transformations of documents containing a xsl-stylesheet PI, either on submission with replace="all" or SVGs, or when applying the transform() extension function.

Config File: config.xslEdit

Sample configuration file:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:template name="config">
			<nocss><!-- When existent, no css-conversion hapens. -->
		<properties> <!--  Accessible at run time from within model('xf-model-config')/instance('xf-instance-config'). -->
			<language>navigator</language> <!-- navigator or default -->
			<format.datetime>MM/dd/yyyy hh:mm:ss</format.datetime>
			<status>... Loading ...</status>
		<!-- JS script code to add. 
		   - When none of the following child elements exist, any elements here are copied 
		   - just after xsltforms.js and before init-scripts. 
			<beforeInit/>	<!-- Added in a separate <script> element, after xsltforms.js and before init-scipts. -->
			<onBeginInit/>	<!-- Added within init-code <script> at the begining of initImpl() function, before any definitions. -->
			<onEndInit/>	<!-- Added within init-code <script> at the end of initImpl() function, after xforms.init() invocation. -->
			<afterInit/>	<!-- Added in a separate <script> element, after init-scripts. -->

Processing InstructionsEdit

A xforms page can specify the following processing-instructions(PI) that act as configuraton parameters:

  • xsltforms-options: It accepts 2 pseudo-attributes, sample:
   <?xsltforms-options debug="yes" lang="en"?>
  • css-conversion: sample:
   <?css-conversion no?>


  • xforms:tree: content-model: (xforms:label?, xforms:item/xforms:label*)


Extension functions supported by XSLTForms:

User-Defined FunctionsEdit

Here is a sample of how to define user-defined XPath functions:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
    nfunc:bogus="Workaround for FF's bug: https://bugzilla.mozilla.org/show_bug.cgi?id=94270"
  <title>User-Defined XPath functions</title>

This is for old versions of XsltForms:

    XPathCoreFunctions['http://example.net/xforms/new-functions/ new-func'] =
        new XPathFunction(
            false,                       /* is accepting context as 1st-arg? */
            XPathFunction.DEFAULT_NONE,  /* context-form as 1st-arg, when (args.length == 0): [ DEFAULT_NONE | DEFAULT_NODE | DEFAULT_NODESET | DEFAULT_STRING ] */ 
            false,                       /* is returning nodes? */
            function() { 
              return "NEW FUNC"; 

This works for new versions of XsltForms:

    XsltForms_xpathCoreFunctions['http://example.net/xforms/new-functions/ new-func'] =
        new XsltForms_xpathFunction(
            false,                       /* is accepting context as 1st-arg? */
            XsltForms_xpathFunction.DEFAULT_NONE,  /* context-form as 1st-arg, when (args.length == 0): [ DEFAULT_NONE | DEFAULT_NODE | DEFAULT_NODESET | DEFAULT_STRING ] */ 
            false,                       /* is returning nodes? */
            function() { 
              return "NEW FUNC"; 
    Hello to <xf:output value="concat('My ', nfunc:new-func())" />.

Arithmetic expressionsEdit

Objects in the javascript: pseudo-URL in xf:load/xf:resource@valueEdit

When the javascript: pseudo-URL is used within the xf:load/xf:resource@value attribute, the id of the enclosing <xf:load> element is contained by the following js object-property: