Book a Demo

Author Topic: XSD Schema generation and omitting modelGroup  (Read 6248 times)

dexterxx

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
XSD Schema generation and omitting modelGroup
« on: April 18, 2018, 07:28:19 pm »
Hi,

I have below definition:

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://mycompany.eu/Cdm/Common/Primitives/IdType/1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://mycompany.eu/Cdm/Common/Primitives/IdType/1" xmlns:ccPit1="http://mycompany.eu/Cdm/Common/Primitives/IdType/1">
<xs:element name="IdType" type="IdType"/>
<xs:complexType name="IdType" mixed="true">
<xs:annotation>
<xs:documentation>Primary ID</xs:documentation>
</xs:annotation>
<xs:sequence/>
<xs:attribute name="contextName" use="optional" type="xs:string">
<xs:annotation>
<xs:documentation>attribute definition ID</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:schema>

Generated using `Package -> XML Technologies -> Generate XSD`

Example of usage:

Code: [Select]
<IdType contextName="whatever">Some kind of value</IdType>

Depends on that, does `<xs:sequence/>` attribute exists in schema or not my Java class generator (jaxb2) which gens sources from XSD generates different type for context property ("Some kind of value").

Diff:
Code: [Select]
Index: IdType-1.xsd
===================================================================
--- IdType-1.xsd (v53)
+++ IdType-1.xsd (v54)
@@ -5,7 +5,6 @@
  <xs:annotation>
  <xs:documentation>Primary ID of attribute definition</xs:documentation>
  </xs:annotation>
- <xs:sequence/>
  <xs:attribute name="contextName" use="optional" type="xs:string">
  <xs:annotation>
<xs:documentation>attribute definition ID</xs:documentation>


Same situation with other modelGroups: choose, all.

Final result:

With unnecessary tag:
Code: [Select]
protected List<String> content
After removing:
Code: [Select]
protected String content;
Is there any way to force EA to not generate that tag in output, when complexType has no elements, but only attributes?
Schema without redundant tag is valid of course.
Generators like `xjc` or `jaxb2` can't be configured to other behavior in this situation.

EA versions affected: 12.1, 13

dexterxx

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: XSD Schema generation and omitting modelGroup
« Reply #1 on: May 24, 2018, 05:23:22 pm »
Bump, any support from sparx? This request is some kind of issue in EA.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XSD Schema generation and omitting modelGroup
« Reply #2 on: May 24, 2018, 05:39:17 pm »
Bump, any support from sparx? This request is some kind of issue in EA.
Hi Dexterxx

Welcome to this forum.
Please be advised that this is a user forum, and as such you are mainly reaching your fellow EA users.
Although Sparx employees do frequent this forum, and help us out from time to time, this is by no means an official channel to get in touch with Sparx Systems.

You can contact Sparx by entering a feature request or a bug report.

I'm not aware of any such option, so in the mean time you might need to fall back on a xslt or something similar.

Geert