XSLTForms since 2009

XSLTForms [XSLTForms] has been compatible with successive browser versions starting from Internet Explorer 4. It is based on XSLT 1.0, CSS and vanilla Javascript. Consequently, XSLTForms is composed of 3 files: xsltforms.xsl, xsltforms.css and xsltforms.js.

This XSLT stylesheet acts as a compiler, generating both HTML elements with a bunch of CSS classes and Javascript instructions. The complex part in it is the XPath 1.0 parser.

For example,

<xf:input ref="PersonGivenName" incremental="true">
 <xf:label>Please enter your first name: </xf:label>
</xf:input>

Becomes

<span id="xsltforms-mainform-input-4_4_2_" class="xforms-disabled xforms-control xforms-input xforms-appearance">
 <span class="focus"> </span>
 <label for="xsltforms-mainform-input-input-4_4_2_" id="xsltforms-mainform-label-2_4_4_2_" class="xforms-label">Please enter your first name: </label>
 <span class="value">
  <input type="text" id="xsltforms-mainform-input-input-4_4_2_" incremental="true" class="xforms-value" />
 </span>
 <span class="xforms-required-icon">*</span>
 <span class="xforms-alert">
  <span class="xforms-alert-icon"> </span>
 </span>
</span>

And

XsltForms_xpath.create(xsltforms_subform,"PersonGivenName",false,
 new XsltForms_locationExpr(false,
  new XsltForms_stepExpr('child',
   new XsltForms_nodeTestName('','PersonGivenName')
  )
 )
);
new XsltForms_input(xsltforms_subform,xsltforms_subform.id + "-input-4_4_2_",2,"text",
 new XsltForms_binding(null, "PersonGivenName"),null,"true",null,null,null
);

XForms 1.1 Recommendation [XF11] is based on XPath 1.0: no sequences, no eq, ne, lt, … operators, no types, ... XSLTForms has its own XPath 1.0 engine in two steps: the parser written in XSLT 1.0 and the evaluator written in Javascript. It is frustrating for authors used to retrieve data from XML databases to be restricted to XPath 1.0 while XQuery/XPath 4.0 is now emerging.

For example,

concat('Hello ', PersonGivenName, '. We hope you like XForms!')

Becomes

new XsltForms_functionCallExpr('http://www.w3.org/2005/xpath-functions concat',
 new XsltForms_cteExpr('Hello '),
 new XsltForms_locationExpr(false,
  new XsltForms_stepExpr('child',
   new XsltForms_nodeTestName('','PersonGivenName')
  )
 ),
 new XsltForms_cteExpr('. We hope you like XForms!')
)

For generating Javascript instructions, XSLT 1.0 is not a very nice approach because of a rather limited function set and just named templates to process strings. For example, performance is not good with very long element names… When applied at client-side, the XSLT stylesheet execution results in a blank-page effect before HTML elements being rendered.