forked from faustedition/faust-gen-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscl2xml.js
executable file
·27 lines (23 loc) · 855 Bytes
/
scl2xml.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
#!/usr/bin/env node
/*
* Very simple script that converts faust-web's sceneLineMapping to XML.
*
* Usage:
* npm install json2xml
* ./scl2xml.js ../faust-web/data/scene_line_mapping.js scenes.xml
*/
var fs = require('fs'),
vm = require('vm'),
json2xml = require('json2xml'),
infile = process.argv[2],
outfile = process.argv[3];
vm.runInThisContext(fs.readFileSync(infile, null, { encoding: "utf8" }));
sceneLineMapping.forEach(function(el, idx, arr) {
// json2xml just concatenates array elements
arr[idx] = { scene: el, attr: { n: el.id } };
});
fs.writeFileSync(outfile,
json2xml({sceneLineMapping: sceneLineMapping,
attr: { xmlns: "http://www.faustedition.net/ns" }},
{ attributes_key: 'attr' }),
{ encoding: "utf8" });