Generating moddle compliant JSON from XML schema definition

Currently working on translating a .xsd file into moddle compliant json.

This being a very time consuming and error prone activity. I am bound to make some mistakes.

Are there any facilities for transforming .xsd to moddle compliant json programatically?

And what schema does moddle actually use/accept?

And what about the use of datatypes such as xs:duration. How might this be incorporated into the json schema without manually breaking down the data-type into its singular elements. Is it possible to reference external definitions, such as xs:duration → XML Schema Date/Time Datatypes ?

What about internal referencing by use of $ref?

Without knowing exactly what schema moddle conforms to its a bit difficult to translate these complex xsd documents into compliant json without breaking them down into atomic parts…

Any pointers on this would be greatly appreciated!



1 Like


There is documentation for moddle schemas: moddle/ at master · bpmn-io/moddle · GitHub

You can also look into BPMN moddle schemas for inspiration: bpmn-moddle/resources/bpmn/json at master · bpmn-io/bpmn-moddle · GitHub

Please have a look at these and come back if you have follow-up questions.




Thank you for the swift reply.

Appreciate the attached BPMN moddle schemas. These are a great reference.

Afraid this does not completely answer my query, let me rephrase:

  • Is it possible to programmatically (read automatically) transform a valid .xsd/xml document to moddle compliant json?
  • or alternatively provide some higher level model which is then transformed into moddle?

Trying to avoid having to transform my .xsd into moddle manually as this is a very consuming and error prone task.

Provided that moddle is (arguably) difficult to work with, i am hoping that you have some facilities that make it a bit simpler to create these moddle descriptors, which can quickly become thousands of lines long…

Thanks again,


All right, I get it. When team built moddle schema for DMN 1.3, we used the cmof-parser. This tool allows you to produce moddle schema out of a CMOF / XMI file. So if you can get such a file instead of the XSD, that should help. We don’t have an XSD → moddle solution, though.

@nikku Is there anything you could add to this?

Awesome. Definitely a step in the right direction. Will have a closer look at this!

1 Like

@hpl002 First of all, interesting case you open here.

Indeed, as @barmac points out we’re generating our schemata from the meta model not the XSD. The XSD is not sufficient for generating it, as it misses type information in crucial places. One example is references. Typically these are implemented via xsd:ID or something like this.

However, from the meta-model perspective the referenced elements are actually typed, i.e. a sequence flow can only reference a FlowNode via SequenceFlow#incoming or SequenceFlow#outgoing.

Generally speaking, try to approach the topic in a test driven manner. It works really nicely for us and it should work well for you, too.