New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"mixed" is not inherited when extending a complex type (BPMN 2.0 schema) #228

Closed
choffmeister opened this Issue Nov 21, 2013 · 7 comments

Comments

Projects
None yet
2 participants
@choffmeister

steps

$ git clone https://github.com/choffmeister/scalaxb-issue-228.git
$ cd scalaxb-issue-228
$ sbt test

problem

Node of type TExpression does not contain the intermixed values from the XML source.

expectations

TExpression should have a field of type Seq[_] that contains the mixed elements (Documentation, raw content, etc.) in the order of occurence in the XML file.

original report

Hi, first of all great work! But I have a little issue with the BPMN 2.0 schema. Code generation from schema works like a charm, but some information from my example BPMN file do not find their way into the object model.

My setup:

  • scalaxb 1.1.2
  • scala 2.10.3
  • sbt 0.13.0

The relevant parts of the schema are:

<xsd:element name="multiInstanceLoopCharacteristics" type="tMultiInstanceLoopCharacteristics"  substitutionGroup="loopCharacteristics"/>
<xsd:complexType name="tMultiInstanceLoopCharacteristics">
    <xsd:complexContent>
        <xsd:extension base="tLoopCharacteristics">
            <xsd:sequence>
                <xsd:element name="loopCardinality" type="tExpression" minOccurs="0" maxOccurs="1"/>
                <xsd:element name="loopDataInputRef" type="xsd:QName" minOccurs="0" maxOccurs="1"/>
                <xsd:element name="loopDataOutputRef" type="xsd:QName" minOccurs="0" maxOccurs="1"/>
                <xsd:element name="inputDataItem" type="tDataInput" minOccurs="0" maxOccurs="1"/>
                <xsd:element name="outputDataItem" type="tDataOutput" minOccurs="0" maxOccurs="1"/>
                <xsd:element ref="complexBehaviorDefinition" minOccurs="0" maxOccurs="unbounded"/>
                <xsd:element name="completionCondition" type="tExpression" minOccurs="0" maxOccurs="1"/>
            </xsd:sequence>
            <xsd:attribute name="isSequential" type="xsd:boolean" default="false"/>
            <xsd:attribute name="behavior" type="tMultiInstanceFlowCondition" default="All"/>
            <xsd:attribute name="oneBehaviorEventRef" type="xsd:QName" use="optional"/>
            <xsd:attribute name="noneBehaviorEventRef" type="xsd:QName" use="optional"/>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="tExpression">
    <xsd:complexContent>
        <xsd:extension base="tBaseElementWithMixedContent"/>
    </xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="tBaseElementWithMixedContent" abstract="true" mixed="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>

I know from different tools (BPMN and XML) that the following XML is valid according to the scheme:

<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
        xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:activiti="http://activiti.org/bpmn"
        typeLanguage="http://www.w3.org/2001/XMLSchema"
        expressionLanguage="http://www.w3.org/1999/XPath"
        targetNamespace="http://www.activiti.org/bpmn2.0">
    <process id="hello">
        <documentation textFormat="text/plain">Hello World!</documentation>
        <startEvent id="theStart">
          <outgoing>flow1</outgoing>
        </startEvent>
        <sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask"/>
        <userTask id="userTask" name="A user task">
          <incoming>flow1</incoming>
          <outgoing>flow2</outgoing>
          <multiInstanceLoopCharacteristics>
            <loopCardinality>10</loopCardinality>
          </multiInstanceLoopCharacteristics>
        </userTask>
        <sequenceFlow id="flow2" sourceRef="userTask" targetRef="theEnd"/>
        <endEvent id="theEnd">
          <incoming>flow2</incoming>
        </endEvent>
    </process>
</definitions>

The <loopCardinality>10</loopCardinality> part causes the issues. The generated object model does not have any field to contain the content (in this case the 10). I know from different tools (BPMN- and XML-tools) that the tExpression type allows content (which is the type of the loopCardinality element). In fact, the element makes no sense without content.

The relevant parts of the object model are:

case class TMultiInstanceLoopCharacteristics(documentation: Seq[de.choffmeister.bpmnmodel.TDocumentation] = Nil,
  extensionElements: Option[de.choffmeister.bpmnmodel.TExtensionElements] = None,
  loopCardinality: Option[de.choffmeister.bpmnmodel.TExpressionable] = None,
  loopDataInputRef: Option[javax.xml.namespace.QName] = None,
  loopDataOutputRef: Option[javax.xml.namespace.QName] = None,
  inputDataItem: Option[de.choffmeister.bpmnmodel.TDataInput] = None,
  outputDataItem: Option[de.choffmeister.bpmnmodel.TDataOutput] = None,
  complexBehaviorDefinition: Seq[de.choffmeister.bpmnmodel.TComplexBehaviorDefinition] = Nil,
  completionCondition: Option[de.choffmeister.bpmnmodel.TExpressionable] = None,
  id: Option[String] = None,
  isSequential: Boolean,
  behavior: de.choffmeister.bpmnmodel.TMultiInstanceFlowCondition,
  oneBehaviorEventRef: Option[javax.xml.namespace.QName] = None,
  noneBehaviorEventRef: Option[javax.xml.namespace.QName] = None,
  attributes: Map[String, scalaxb.DataRecord[Any]]) extends TLoopCharacteristics 

trait TLoopCharacteristics extends TBaseElement {
  val documentation: Seq[de.choffmeister.bpmnmodel.TDocumentation]
  val extensionElements: Option[de.choffmeister.bpmnmodel.TExtensionElements]
  val id: Option[String]
  val attributes: Map[String, scalaxb.DataRecord[Any]]
}

trait TBaseElement {
  val documentation: Seq[de.choffmeister.bpmnmodel.TDocumentation]
  val extensionElements: Option[de.choffmeister.bpmnmodel.TExtensionElements]
  val id: Option[String]
  val attributes: Map[String, scalaxb.DataRecord[Any]]
}

case class TExpression(documentation: Seq[de.choffmeister.bpmnmodel.TDocumentation] = Nil,
  extensionElements: Option[de.choffmeister.bpmnmodel.TExtensionElements] = None,
  id: Option[String] = None,
  attributes: Map[String, scalaxb.DataRecord[Any]]) extends TExpressionable

case class TFormalExpression(documentation: Seq[de.choffmeister.bpmnmodel.TDocumentation] = Nil,
  extensionElements: Option[de.choffmeister.bpmnmodel.TExtensionElements] = None,
  id: Option[String] = None,
  language: Option[java.net.URI] = None,
  evaluatesToTypeRef: Option[javax.xml.namespace.QName] = None,
  attributes: Map[String, scalaxb.DataRecord[Any]]) extends TExpressionable

trait TExpressionable extends TBaseElementWithMixedContent with TTimerEventDefinitionOption {
  val documentation: Seq[de.choffmeister.bpmnmodel.TDocumentation]
  val extensionElements: Option[de.choffmeister.bpmnmodel.TExtensionElements]
  val id: Option[String]
  val attributes: Map[String, scalaxb.DataRecord[Any]]
}

trait TBaseElementWithMixedContent {
  val id: Option[String]
  val attributes: Map[String, scalaxb.DataRecord[Any]]
}

At https://github.com/choffmeister/bpmn-model you can find a prepared SBT project with the BPMN scheme files configured. Would be great if one could investigate this problem. Seems like an instance of a problem, that will arise in other schemes, too.

Greetz, Christian

@choffmeister

This comment has been minimized.

Show comment
Hide comment
@choffmeister

choffmeister Nov 21, 2013

Could the problem arise because of the mixed=true attribute at tBaseElementWithMixedContent being ignored? See http://www.w3schools.com/schema/schema_complex_mixed.asp

Could the problem arise because of the mixed=true attribute at tBaseElementWithMixedContent being ignored? See http://www.w3schools.com/schema/schema_complex_mixed.asp

@choffmeister

This comment has been minimized.

Show comment
Hide comment
@choffmeister

choffmeister Nov 21, 2013

Just found your issue guidelines... Here again short:

Steps:

$ git clone https://github.com/choffmeister/scalaxb-issue-228.git
$ cd scalaxb-issue-228
$ sbt test

Problem:
Node of type TExpression does not contain the intermixed values from the XML source.

Expectation:
TExpression should have a field of type Seq[_] that contains the mixed elements (Documentation, raw content, etc.) in the order of occurence in the XML file.

Just found your issue guidelines... Here again short:

Steps:

$ git clone https://github.com/choffmeister/scalaxb-issue-228.git
$ cd scalaxb-issue-228
$ sbt test

Problem:
Node of type TExpression does not contain the intermixed values from the XML source.

Expectation:
TExpression should have a field of type Seq[_] that contains the mixed elements (Documentation, raw content, etc.) in the order of occurence in the XML file.

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Nov 21, 2013

Owner

Thanks for the detailed bug report. It does look like mixed is not being processed from your output.
I'll take a look at this more later.

Owner

eed3si9n commented Nov 21, 2013

Thanks for the detailed bug report. It does look like mixed is not being processed from your output.
I'll take a look at this more later.

@ghost ghost assigned eed3si9n Jan 5, 2014

eed3si9n added a commit that referenced this issue Jan 5, 2014

@eed3si9n eed3si9n closed this in 47fab0c Jan 5, 2014

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Jan 5, 2014

Owner

Fixed this and published 1.1.3-SNAPSHOT. After changing the numbers in your spec, it passed.

      loopCardinality.toString must contain("12")
      loopCardinality.toString must contain("34")
Owner

eed3si9n commented Jan 5, 2014

Fixed this and published 1.1.3-SNAPSHOT. After changing the numbers in your spec, it passed.

      loopCardinality.toString must contain("12")
      loopCardinality.toString must contain("34")
@choffmeister

This comment has been minimized.

Show comment
Hide comment
@choffmeister

choffmeister Jan 6, 2014

Very nice. Will try this out as soon as I find time. Big thanks!

Very nice. Will try this out as soon as I find time. Big thanks!

@choffmeister

This comment has been minimized.

Show comment
Hide comment
@choffmeister

choffmeister Jan 10, 2014

Works great. I also updated my issue repository choffmeister/scalaxb-issue-228@036d8c4. Do you want me to keep the repository?

Works great. I also updated my issue repository choffmeister/scalaxb-issue-228@036d8c4. Do you want me to keep the repository?

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Jan 10, 2014

Owner

Thanks for the confirmation. You can delete the repo if you want.

Owner

eed3si9n commented Jan 10, 2014

Thanks for the confirmation. You can delete the repo if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment