How to use moddle-xml - 6 common examples

To help you get started, we’ve selected a few moddle-xml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpmn-io / bpmn-js / lib / Model.js View on Github external
function fromXML(xmlStr, typeName, options, callback) {

  if (!_.isString(typeName)) {
    callback = options;
    options = typeName;
    typeName = 'bpmn:Definitions';
  }

  if (_.isFunction(options)) {
    callback = options;
    options = {};
  }

  var model = instance();

  var reader = new xml.Reader(model, options);
  var rootHandler = reader.handler(typeName);

  reader.fromXML(xmlStr, rootHandler, function(err, result) {
    callback(err, result, rootHandler.context);
  });
}
github bpmn-io / bpmn-moddle / lib / bpmn-moddle.js View on Github external
BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {

  if (!isString(typeName)) {
    done = options;
    options = typeName;
    typeName = 'bpmn:Definitions';
  }

  if (isFunction(options)) {
    done = options;
    options = {};
  }

  var reader = new Reader(assign({ model: this, lax: true }, options));
  var rootHandler = reader.handler(typeName);

  reader.fromXML(xmlStr, rootHandler, done);
};
github bpmn-io / bpmn-moddle / lib / Bpmn.js View on Github external
function fromXML(xmlStr, typeName, options, callback) {

    if (!_.isString(typeName)) {
      callback = options;
      options = typeName;
      typeName = 'bpmn:Definitions';
    }

    if (_.isFunction(options)) {
      callback = options;
      options = {};
    }

    var reader = new xml.Reader(model, options);
    var rootHandler = reader.handler(typeName);

    reader.fromXML(xmlStr, rootHandler, function(err, result) {
      callback(err, result, rootHandler.context);
    });
  }
github bpmn-io / bpmn-moddle / lib / Bpmn.js View on Github external
function toXML(element, options, callback) {

    if (_.isFunction(options)) {
      callback = options;
      options = {};
    }

    var writer = new xml.Writer(options);
    try {
      var result = writer.toXML(element);
      callback(null, result);
    } catch (e) {
      callback(e);
    }
  }
github bpmn-io / bpmn-js / lib / Model.js View on Github external
function toXML(element, options, callback) {

  if (_.isFunction(options)) {
    callback = options;
    options = {};
  }

  var writer = new xml.Writer(options);
  try {
    var result = writer.toXML(element);
    callback(null, result);
  } catch (e) {
    callback(e);
  }
}
github bpmn-io / bpmn-moddle / lib / bpmn-moddle.js View on Github external
BpmnModdle.prototype.toXML = function(element, options, done) {

  if (isFunction(options)) {
    done = options;
    options = {};
  }

  var writer = new Writer(options);

  var result;
  var err;

  try {
    result = writer.toXML(element);
  } catch (e) {
    err = e;
  }

  return done(err, result);
};

moddle-xml

XML import/export for documents described with moddle

MIT
Latest version published 9 months ago

Package Health Score

74 / 100
Full package analysis

Popular moddle-xml functions