Book a Demo

Author Topic: XSD generation fails with enumerations  (Read 5551 times)

tlw1999

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
XSD generation fails with enumerations
« on: March 23, 2013, 06:56:35 am »
I've asked for priority support on this but have not received any response from Sparx yet.  Anyone have any ideas?

I’ve been struggling with a problem I don’t seem to be able to resolve.  Here’s the behavior.  I can import a XSD file that is valid (It validates in other tools) and which reports no errors on import (see xml below).   However, when I generate the XSD from exactly the same package that results from the import, EA hits one of the top element definitions and errors, reporting this message --> [Checking Class: ValidUser ... Invalid connections found, these will be ignored].

The problem occurs when the XSD defines a simpleType with enumerations (shown below). It imports the relationship between the XSDsimpleType (in this case YesOrNo) and the XSDtopLevelElement as a generalisation.   EA doesn’t seem to be able to handle an association of an enumeration type with a top level element.  Can you advise if this a bug, if there is a work around that will allow this to work, or any other alternative?  This seems like it should be basic XML, Schema capability but maybe its the way it needs to be modeled?  I could really use this ASAP. I spent quite a bit of time trying to determine the problem.


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://xyz.com/RD/BaseTypes/BaseType/v1" xmlns="http://xyz.com/RD/BaseTypes/BaseType/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0">
     <xsd:simpleType name="Text-1">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="1"/>
           </xsd:restriction>
     </xsd:simpleType>
     <xsd:simpleType name="Text-3">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="3"/>
           </xsd:restriction>
     </xsd:simpleType>
     <xsd:simpleType name="Text-4">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="4"/>
           </xsd:restriction>
     </xsd:simpleType>
     <xsd:simpleType name="Text-5">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="5"/>
           </xsd:restriction>
     </xsd:simpleType>
     <xsd:simpleType name="Text-6">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="6"/>
           </xsd:restriction>
     </xsd:simpleType>
     <xsd:simpleType name="Text-8">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="8"/>
           </xsd:restriction>
     </xsd:simpleType>
     <xsd:simpleType name="YesOrNo">
           <xsd:restriction base="xsd:string">
                <xsd:maxLength value="3"/>
                <xsd:enumeration value="Yes"/>
                <xsd:enumeration value="No"/>
           </xsd:restriction>
     </xsd:simpleType>
</xsd:schema>


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://xyz.com/RD/Services/Sample/v1" xmlns:base="http://xyz.com/RD/BaseTypes/BaseType/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xyz.com/RD/Services/Sample/v1" version="1.0">
     <xsd:import namespace="http://xyz.com/RD/BaseTypes/BaseType/v1" schemaLocation="BaseTypes.xsd"/>
     <xsd:element name="ValidUser" type="base:YesOrNo"/>
     <xsd:element name="ActiveUser" type="base:YesOrNo"/>
     <xsd:element name="UserName" type="base:Text-8"/>
     <xsd:complexType name="SampleType">
           <xsd:sequence>
                <xsd:element ref="ValidUser"/>
                <xsd:element ref="ActiveUser"/>
                <xsd:element ref="UserName"/>
           </xsd:sequence>
     </xsd:complexType>
</xsd:schema>

What then gets generated is:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://xyz.com/RD/Services/Sample/v1" xmlns:base="http://xyz.com/RD/BaseTypes/BaseType/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xyz.com/RD/Services/Sample/v1" version="1.0">
     <xsd:import namespace="http://xyz.com/RD/BaseTypes/BaseType/v1" schemaLocation="BaseTypes.xsd"/>
     <xsd:element name="ValidUser"/>
     <xsd:element name="ActiveUser"/>
     <xsd:element name="UserName" type="base:Text-8"/>
     <xsd:complexType name="SampleType">
           <xsd:sequence>
                <xsd:element ref="ValidUser" minOccurs="1" maxOccurs="1"/>
                <xsd:element ref="ActiveUser" minOccurs="1" maxOccurs="1"/>
                <xsd:element ref="UserName" minOccurs="1" maxOccurs="1"/>
           </xsd:sequence>
     </xsd:complexType>
</xsd:schema>

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: XSD generation fails with enumerations
« Reply #1 on: March 23, 2013, 01:03:49 pm »
Try Project/Model Validation/Configure: turn off the Relation options. This might help (?!).

q.

tlw1999

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: XSD generation fails with enumerations
« Reply #2 on: March 24, 2013, 06:28:53 am »
Thanks for the advice.  I didn't realise these options existed.

However, completely disabling all checks does not prevent the error on XML Schema generation.  I get the same behavior with all checks turned off.   However, it's clearer what the problem is:

MVR050002 - error (<anonymous> (Generalization)): Generalization is not legal for ValidUser --> YesOrNo      

The problem is this is a widely used Schema technique:  Simpletype of enumerations --> Top Level Element --> Element Ref

Any additional advice?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: XSD generation fails with enumerations
« Reply #3 on: March 24, 2013, 09:46:07 am »
Sure. See the bug report link bottom right of this page  ;)

q.