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

dexterxx

  • EA Novice
  • *
  • Posts: 1
  • 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