Simple Element Values in Moddle XML?

What We Are Trying to Achieve

We are trying to embed GraphML elements in BPMN and CMMN files using Moddle so we can use GraphML (via TinkerPop and Gremlin) to embed and then traverse complex relationships between resources. These are almost always references to resources that sit on other systems and, so, we are considering the use of a graph database to manage these relationships, their integrity, etc. Perhaps this background info isn’t important, but I provide it as context.

Upon saving these BPMN and CMMN files enriched with GraphML elements, the back end will parse out anything with the graphml: namespace and use it to handle any required CRUD methods on a graph database. In other words, we don’t expect Camunda to do anything with the GraphML stuff except tolerate its presence inside the BPMN and CMMN files.

What We Are Struggling With

We are still beginners when it comes to Moddle, but we have had success embedding our own non-GraphML custom elements into BPMN files without any problems. It is clear how to create attributes and attribute values because BPMN seems to favour attributes over simple elements.

Unfortunately GraphML uses both attributes and element values, like so:

  <node id='46'>
    <data key='labelV'>airport</data>
    <data key='type'>airport</data>
    <data key='code'>DTW</data>
    <data key='icao'>KDTW</data>
    <data key='city'>Detroit</data>
    <data key='desc'>Detroit Metropolitan, Wayne County</data>
    <data key='region'>US-MI</data>
    <data key='runways'>6</data>
    <data key='longest'>12003</data>
    <data key='elev'>645</data>
    <data key='country'>US</data>
    <data key='lat'>42.2123985290527</data>
    <data key='lon'>-83.353401184082</data>
  </node>

  <edge id='47' source='1' target='3'>
    <data key='labelE'>route</data>
    <data key='dist'>811</data>
  </edge>
  1. Can Moddle-XML handle element values, as above? What is the proper Moddle descriptor format? I tried isAttr:false but it didn’t seem to work.
  2. Also (and less important) It seems that Moddle (or BPMN) insist on the namespace prefix. Is this a requirement? If it is a requirement, we can use graphml: as the prefix and strip it out at the processing stage. If it is not a requirement, then I would prefer to make node and edge elements un-prefixed.

Here is my Moddle Descriptor:

{
    "name": "GraphML",
    "uri": "http://graphml.graphdrawing.org/xmlns",
    "prefix": "graphml",
    "xml": {
      "tagAlias": "lowerCase"
    },
    "associations": [],
    "types": [    
    {
        "name": "node",
        "superClass": [ "Element" ],
        "meta": {
        "allowedIn": [
            "bpmn:DataStoreReference",
            "bpmn:ServiceTask"
        ]
        },
        "properties": [
        {
            "name": "data",
            "type": "data",
            "isMany": true
        },
        {
            "name": "id",
            "type": "String",
            "isAttr": true
        }
        ]
    },
    {
        "name": "edge",
        "superClass": [ "Element" ],
        "meta": {
        "allowedIn": [
            "bpmn:DataStoreReference",
            "bpmn:ServiceTask"
        ]
        },
        "properties": [
        {
            "name": "data",
            "type": "data",
            "isMany": true
        },
        {
            "name": "id",
            "type": "String",
            "isAttr": true
        },
        {
            "name": "source",
            "type": "String",
            "isAttr": true
        },
        {
            "name": "target",
            "type": "String",
            "isAttr": true
        }
        ]
    },
    {
        "name": "key",
        "superClass": [ "Element" ],
        "meta": {
        "allowedIn": [
            "bpmn:Process",
            "cmmn:Case"
        ]
        },
        "properties": [
        {
            "name": "id",
            "type": "String",
            "isAttr": true
        },
        {
            "name": "for",
            "type": "String",
            "isAttr": true
        },
        {
            "name": "attr.type",
            "type": "String",
            "isAttr": true
        },
        {
            "name": "attr.name",
            "type": "String",
            "isAttr": true
        }
        ]
    },
    {
        "name": "data",
        "superClass": [ "Element" ],
        "properties": [
        {
            "name": "key",
            "type": "String",
            "isAttr": true
        }
        ]
    }],
    "emumerations": [ ]
  }
1 Like

I think I figured it out. I need to use isBody: true instead of isAttr: true.

2 Likes