-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (41 loc) · 1.48 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const transformer = require('enketo-transformer');
async function transform() {
let xform = `<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>basic</h:title>
<model>
<instance>
<basic id="basic">
<height/>
</basic>
</instance>
<bind nodeset="height" type="int"/>
</model>
</h:head>
<h:body>
<input ref="height">
<label>what is your height</label>
</input>
</h:body>
</h:html>`;
let transformed = await transformer.transform({
// required string of XForm
xform,
// optional string, to add theme if no theme is defined in the XForm
// theme: '',
// optional map, to replace jr://..../myfile.png URLs
// media: {
// 'myfile.png': '/path/to/somefile.png',
// },
// optional ability to disable markdown rendering (default is true)
// markdown: true,
// optional preprocess function that transforms the XForm (as libXMLJs object) to
// e.g. correct incompatible XForm syntax before Enketo's transformation takes place
// preprocess: (doc) => doc,
});
return transformed;
}
// Print the result for someone else to consume.
// console.log('test');
transform().then((result) => console.log(result))