cxml
cxml copied to clipboard
JSON to XML
Having parsed a musicxml document into JSON using cxml. I can update the JSON and render it visually. Can you think a way of exporting the JSON back to musicxml after modifications.
I'd also like to create a JSON musicxml doc from scratch using javascript. Whilst i can create the json using duck typing - it doesn't have the XmlType wrappers which means that handling it in rendering engine is different/harder (e.g. no _exists). Some of the types that I wish to create don't seem to have constructors.
Looking at the following which was created using cxsd: https://github.com/owennewo/musicxml-ts/blob/master/app/xmlns/www.musicxml.org.d.ts
I can create a note
let note = new musicxml.note();
but not
let measure = new musicxml.measure();
The latter gives
TypeError: musicxml.measure is not a constructor
The new version in rewrite
branch will include a Writer
class. The pipeline will be first a tokenizer written in C++ and JavaScript, which emits a stream of tokens like opening element name, attribute name, attribute value... Optionally they can be fed into a "DOM/JSON builder" that produces output as the currently released version. The writer can then consume the JSON or the token stream (latter is much faster) and produce XML.
Unfortunately the token stream will still take at least two weeks of work, and the redesigned JSON support maybe an additional month.