Author Topic: How to change XSD generation to flat style?  (Read 2081 times)

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
How to change XSD generation to flat style?
« on: March 17, 2022, 09:07:09 pm »
Some time ago I created a XSDschema package to generate an XML schema. The XML schema is taken as an input to XMLBeans for Java code generation.
XMLBeans works best for me, if I define just one top element and associate other complex types to it.
The result shall be totally flat, no nested element definitions inside complex types. Elements in a Sequence should just refer to types on the outer level.
This worked some time ago.
Now I had to introduce an extention (named runnable). The Schema Composer/Export XSD generates all complex types in a flat manner for all older classes. But all newly introduced classes are generated in an unwanted nested style (with some errors as well, non-associated complex types added as elements in the Sequence).
I was not able to find the difference between the new and the old complex types.
I have zipped the eapx and the generaed result here. (updated to include the eapx and the expected XML schema generation result, that I did manually.)

I would really appriciate if someone would get me back on track, so that a completely flat XML schema will be generated.
« Last Edit: March 17, 2022, 10:36:14 pm by ngong »
Rolf

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: How to change XSD generation to flat style?
« Reply #1 on: March 17, 2022, 10:38:32 pm »
updated
Rolf

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: How to change XSD generation to flat style?
« Reply #2 on: March 20, 2022, 02:16:52 am »
The solution was simple:

I forgot to move the classes (ComplexTypes) from under the outer class to the top level. This means that the XSD generation is sensitive not only to the associations between the classes but also to the hierarchy in the project browser.

Once you know, its simple.
Rolf

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8599
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to change XSD generation to flat style?
« Reply #3 on: March 20, 2022, 11:12:59 am »
The solution was simple:

I forgot to move the classes (ComplexTypes) from under the outer class to the top level. This means that the XSD generation is sensitive not only to the associations between the classes but also to the hierarchy in the project browser.

Once you know, it's simple.
Hi Rolf,
This is another example of the conflation of nesting with composition, that plagues the current implementation.  Nesting should be reserved for access specification.  The XML generator correctly read the previous nesting as the hierarchical access path and generated a "deep" result.  Once you corrected the incorrect structure, the generator produced your desired result.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!