Skip to content
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

Fix for wrong namespace specification of XML element attribute of derived types #141

Merged
merged 2 commits into from Sep 28, 2019

Conversation

ivanpovazan
Copy link

@ivanpovazan ivanpovazan commented Sep 27, 2019

The title is most probably very confusing and I apologize for that. I will try to explain the issue in the following lines :)
I was using the library for generating classes from BPMN standard xsd files.
However, I have noticed a problem with substitution groups in a circular type dependency scenario, when type defines an element of same owning type which is derived in an external namespace.

The example for this can be seen in BPMNDI.xsd and DI.xsd which specify:

  1. bpmndi:BPMNShape element with type=bpmndi:BPMNShape and substitution group=di:DiagramElement
  2. di:DiagramElement complex type
  3. di:Plane complex type specifying sub-element of di:DiagramElement type

Since BPMNShape (and also BPMNEdge) is a derived type from a different namespace Serialization.XmlElementAttribute for DiagramElement property of Plane class needs to include the namespace where BPMNShape is defined. Currently the namespace of the Plane type is used, which is incorrect.

I have provided a fix and also a test case which checks a very simple BPMN xml file which utilizes these types. The intention was not to test full BPMN spec, since it is a really large standard, but to solve this one problem with XML polymorphism.

Thanks!

PS It might be that such definition of types is not allowed in the XSD standard, but it is used like that in BPMN specification. Let me know if you need more input for the exact source of the problem and further explanations.

ivan added 2 commits September 26, 2019 23:59
…are defined in different namespaces compared to owning type namespace
…f BPMN standard

Test is using:
- xsd files taken from https://www.omg.org/spec/BPMN/2.0/About-BPMN/
- xml example file created with https://demo.bpmn.io tool
Note: this is a simple example not a use case of BPMN standard, but reflects the problem of wrong namespace generation for derived types
@codecov
Copy link

codecov bot commented Sep 27, 2019

Codecov Report

Merging #141 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #141      +/-   ##
==========================================
+ Coverage   95.28%   95.29%   +<.01%     
==========================================
  Files          17       17              
  Lines        2544     2549       +5     
==========================================
+ Hits         2424     2429       +5     
  Misses        120      120
Impacted Files Coverage Δ
XmlSchemaClassGenerator/TypeModel.cs 95.39% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78b1ccb...10388bf. Read the comment docs.

@mganss mganss merged commit 0e5e71b into mganss:master Sep 28, 2019
@mganss
Copy link
Owner

mganss commented Sep 28, 2019

Thank you!

@ivanpovazan
Copy link
Author

You are very welcome :)

I will add some more BPMN examples for testing, and I also have a fix for custom csharp namespace generation ready just need to do some final checks.

Btw, when will these be included in an official release?

Thank you!

@mganss
Copy link
Owner

mganss commented Oct 2, 2019

I'll make a release after #143 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants