cancel
Showing results for 
Search instead for 
Did you mean: 

Extending BPMN Parser

iravanchi
Champ in-the-making
Champ in-the-making
Regarding the discussion about extending the BPMN parser (http://forums.activiti.org/en/viewtopic.php?f=4&t=305)

The BPMN XSD, allows extending all BPMN elements (including flows, tasks, gateways, etc.) with any custom property, provided that the additional attributes are not in the BPMN namespace:

   <xsd:element name="baseElement" type="tBaseElement"/>
   <xsd:complexType name="tBaseElement" abstract="true">
      <xsd:sequence>
         <xsd:element ref="documentation" minOccurs="0" maxOccurs="unbounded"/>
         <xsd:element ref="extensionElements" minOccurs="0" maxOccurs="1" />
      </xsd:sequence>
      <xsd:attribute name="id" type="xsd:ID" use="optional"/>
      <xsd:anyAttribute namespace="##other" processContents="lax"/>
   </xsd:complexType>

Also, all BPMN elements can contain a <extensionElements> element, which is free to have any XML content:


   <xsd:element name="extensionElements" type="tExtensionElements" />
   <xsd:complexType name="tExtensionElements">
      <xsd:sequence>
         <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
      </xsd:sequence>
   </xsd:complexType>

The <extension> element is used to declare extensions required to parse the file.
So, I guess we need to look at the <extension> elements in the XML file, and see if there are extension handlers ready to handle such definitions. If there are <extension> declarations that their "mustUnderstand" is true, and there's no one to handle, the parser should raise an error.

Otherwise, I'm thinking that when parsing each XML element, if there are any extensions specified (either attribute, or in <extensionElements>) we should group them in namespaces (the extensions can be from different namespaces) and then hand them to the extension handlers.

The handler should have the ability to influence PVM object model generation in any way.

I think "activiti:" extensions should also be treated the same way Parser treats other extensions.

What's your idea? Does it seem right?

I have two specific questions too, if anyone has any idea about it:

1. What is the formal meaning of the "definition" attribute in <extension> element? It should be an xsd:QName. Is it just an identifier, or does it have any specific meaning (relation to extension XSD?) that is specified in the BPMN 2.0 spec?

2. In the example in BPMN2.0 spec document, there are two violations of this XSD thing. Here's the sample:

<bpmn:task name="Retrieve Customer Record" id="ID_2">
    <bpmn:dataInput name="Order Input" id="ID_3">
        <bpmn:typeDefinition typeRef="bo:Order" id="ID_4"/>
    </bpmn:dataInput>
    <bpmn:dataOutput name="Customer Record Output" id="ID_5">
        <bpmn:typeDefinition typeRef="bo:CustomerRecord" id="ID_6"/>
    </bpmn:dataOutput>
    <bpmn:inputSet name="Inputs" id="ID_7" dataInputRefs="ID_3"/>
    <bpmn:outputSet name="Outputs" id="ID_8" dataOutputRefs="ID_5"/>
</bpmn:task>
First violation: extension elements are not contained in an <extensionElements> node.
Second violation: extensions are also using the same "bpmn:" namespace, where XSD specifies namespace="##other".
Am I right? Or there's something I'm missing here?
10 REPLIES 10

chaoyy
Champ in-the-making
Champ in-the-making
If need to modify org.activiti.engine.impl.bpmn.parser.BpmnParse class?