Generating Go code from BPMN schemas
georgeroman opened this issue · comments
George Roman commented
Hello! I'm trying to generate Go code based on the BPMN schemas (they can be found in the previous link - BPMN20.xsd
being the main one).
Here is the generated Go code for the BPMN20.xsd
schema:
// Copyright 2020 The xgen Authors. All rights reserved.
//
// DO NOT EDIT: generated by xgen XSD generator
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package schema
import (
"encoding/xml"
)
// Definitions ...
type Definitions *TDefinitions
// TDefinitions ...
type TDefinitions struct {
XMLName xml.Name `xml:"tDefinitions"`
IdAttr string `xml:"id,attr,omitempty"`
NameAttr string `xml:"name,attr,omitempty"`
TargetNamespaceAttr string `xml:"targetNamespace,attr"`
ExpressionLanguageAttr string `xml:"expressionLanguage,attr,omitempty"`
TypeLanguageAttr string `xml:"typeLanguage,attr,omitempty"`
ExporterAttr string `xml:"exporter,attr,omitempty"`
ExporterVersionAttr string `xml:"exporterVersion,attr,omitempty"`
Import []*TImport `xml:"import"`
Extension []*TExtension `xml:"extension"`
RootElement []*TRootElement `xml:"rootElement"`
BpmndiBPMNDiagram []*BPMNDiagram `xml:"bpmndi:BPMNDiagram"`
Relationship []*TRelationship `xml:"relationship"`
}
// Import ...
type Import *TImport
// TImport ...
type TImport struct {
XMLName xml.Name `xml:"tImport"`
NamespaceAttr string `xml:"namespace,attr"`
LocationAttr string `xml:"location,attr"`
ImportTypeAttr string `xml:"importType,attr"`
}
Also, here is an example BPMN file:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI">
<bpmn:process id="Process">
<bpmn:startEvent id="foo" name="foo">
<bpmn:extensionElements>
<foo/>
</bpmn:extensionElements>
<bpmn:outgoing>Foo</bpmn:outgoing>
<bpmn:messageEventDefinition id="foo" messageRef="foo" />
</bpmn:startEvent>
<bpmn:task id="foo4" name="foo">
<bpmn:extensionElements>
<foo/>
</bpmn:extensionElements>
<bpmn:incoming>foo</bpmn:incoming>
</bpmn:task>
<bpmn:sequenceFlow id="foo" sourceRef="foo" targetRef="foo" />
</bpmn:process>
<bpmn:message id="foo" name="foo" />
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="Process">
<bpmndi:BPMNShape bpmnElement="foo">
<dc:Bounds x="32.84375" y="47.5" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="foo">
<dc:Bounds x="214.84375" y="100.5" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="foo">
<di:waypoint x="50.84375" y="65.5" />
<di:waypoint x="264.84375" y="140.5" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
The issue I have is that I can't figure out how to unmarshal definitions
elements (they appear in the generated code as type Definitions *TDefinitions
). Shouldn't they be documented with `xml:"definitions"`
in order for the XML parser to be able to parse them? I'm new to go so it's very possible that I'm missing something here.
Thank you in advance!