Skip to content

EXIficient/exificient.js

Repository files navigation

exificient.js

JavaScript Implementation of EXI and EXI for JSON

Build Status

How to get

NPM

https://www.npmjs.com/package/exificient.js

npm install exificient.js

unpkg, CDN (content delivery network)

https://unpkg.com/[email protected]/dist/exificient.js

Demo

An online demonstration can be found here: http://exificient.github.io/javascript/demo/.

How to use

HowTo for EXIforJSON

// encode JSON object
var uint8Array = EXI4JSON.exify(jsonObjIn);

// decode EXIforJSON
var jsonObjOut = EXI4JSON.parse(uint8Array);

HowTo for EXI

// Note: the necessary grammars can be generated from XML schema using
// the project https://github.com/EXIficient/exificient-grammars
// class com.siemens.ct.exi.grammars.persistency.Grammars2JSON 

// encode XML
var exiEncoder = new EXIEncoder(grammars);	
exiEncoder.encodeXmlText(textXML);
var uint8ArrayLength = exiEncoder.getUint8ArrayLength();
var uint8Array = exiEncoder.getUint8Array();

// decode EXI to XML again
var exiDecoder = new EXIDecoder(grammars);
var xmlHandler = new XMLEventHandler(); // register XML handler
exiDecoder.registerEventHandler(xmlHandler);
exiDecoder.decode(arrayBuffer); // EXI input data
xmlHandler.getXML(); // get XML