npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

medic-enketo-xslt

v1.5.0

Published

XSL stylesheets for the Enketo XForm transformation to be run client-side in a web browser

Downloads

54

Readme

Enketo XSLT

Build Status

XSLT sheets used to transform OpenRosa-flavoured XForms into an HTML form and XML instance.

This is a fork of enketo-xslt, modified to run client-side, in a web browser.

Browser Support

We commonly test on:

  • Firefox
  • Chrome

Examples

Code

(This example uses jQuery to parse strings into XMLDocument instances.)

var htmlTransformXsltAsString = // loaded somehow
var modelTransformXsltAsString = // loaded somehow
var htmlTransformXslt = jQuery.parseXML(htmlTransformXsltAsString);
var modelTransformXslt = jQuery.parseXML(modelTransformXsltAsString);

var xformXmlAsString = // loaded somehow
var xformXml = jQuery.parseXML(xformXmlAsString);

function transform(xslt, xml) {
	var p = new XSLTProcessor();
	p.importStylesheet(xslt);

	var transformed = p.transformToDocument(xml);

	var root = transformed.documentElement.firstElementChild;
	return new XMLSerializer().serializeToString(root);
}

var formHtml = transformed(htmlTransformXslt, xformXml);
var formModel = transformed(modelTransformXslt, xformXml);

src/

There is a fuller example in this repository at examples/index.js.

In the wild

You can find examples of this code in use in medic-webapp and enketo-collect.

Use

Use with npm

npm install medic-enketo-xslt

Use without npm and in any programming language.

Use as git submodule and read the two .xsl files as required. Ignore index.js.

License

See license document.

In addition, any product that uses enketo-xslt is required to have a "Powered by Enketo" footer, according to the specifications below, on all screens in which the output of enketo-xslt, or parts thereof, are used, unless explicity exempted from this requirement by Enketo LLC in writing. Partners and sponsors of the Enketo Project, listed on https://enketo.org/#about and on https://github.com/enketo/enketo-core#sponsors are exempted from this requirements and so are contributors listed in package.json.

The aim of this requirement is to force adopters to give something back to the Enketo project, by at least spreading the word and thereby encouraging further adoption.

Specifications:

  1. The word "Enketo" is displayed using Enketo's logo.
  2. The minimum font-size of "Powered by" is 12 points.
  3. The minimum height of the Enketo logo matches the font-size used.
  4. The Enketo logo is hyperlinked to https://enketo.org

Example:

Powered by

Change Log

See change log

XSL Changes

To suport XSL transformations in browser, we must make a few changes to the upstream stylesheets:

  • change XSL version from 2.0 to 1.0
  • change <xsl:message> calls to <xsl:comment>
  • change x != y comparisons to not(x = y)
  • only use str:tokenize within a feature switch (not supported on all browsers)
  • work around some unclear browser weirdness relating to <xsl-apply-templates>

And for our own reasons, we make the following changes:

  • Do not include `No Title when we did not set a title in the XForm
  • add explicit support for tel data type, to allow nice soft-keyboard support on touchscreen devices
  • add support for unknown data types (treat them all as string/text)

It would also be nice to minify the XSL files before use in production, to minimise transmission size. This could include stripping meaningless whitespace, and XML comments. However, there are some inline comments in the stylesheets which may be required to preserve empty tags in place of self-closing ones.

Feature differences from upstream

The above changes necessitate some differences in features from the standard enketo-xslt lib lib:

  • only a single or-appearance can be applied to a particular input node.
  • jr:constraintMsg and jr:requiredMsg cannot have dynamic content