BindGen Does Not Create Valid XSD When Class Contains a Class and Its Subclass 
as Properties
--------------------------------------------------------------------------------------------

                 Key: JIBX-405
                 URL: http://jira.codehaus.org/browse/JIBX-405
             Project: JiBX
          Issue Type: Improvement
          Components: BindGen
    Affects Versions: JiBX 1.2.2
         Environment: Windows Server 2003/Mac OS X Snow Leopard
            Reporter: Jack Vinijtrongjit


Here the scenario:

- ClassA has one variable of type Boolean.
- ClassB extends classA and has one additional variable of type String
- ClassC has 2 variables, one of type ClassA and one of type ClassB
 
JIBX uses "ref" instead of "type' for ClassA elements. This is an issue when 
there are more than one of ClassA-typed child elements in ClassC since you 
cannot have more than an element with the same name.

<xs:element ref="tns:classA" minOccurs="0"/> should be <xs:element name="a" 
type="tns:classA" minOccurs="0"/>

I would normally use an array if there are multiple objects of the same class, 
but that's not how it was done by my colleagues and since it's a normal 
practice in Java, it's difficult to convince them to change. There are actually 
3 other scenarios that are particularly problematic with JIBX, but this is the 
one that is causing me the most issue at this point.

----

public class ClassA {
        private Boolean yesNo;
        
        public ClassA(){                
        }
}

public class ClassB extends ClassA{
        private String remarks;
        
        public ClassB(){                
        }
}

public class ClassC {
        private ClassA a;
        private ClassB b;
        
        public ClassC(){
                
        }
}

---

<target name="bindgen">
    <echo message="Running BindGen tool"/>
    <java classpathref="classpath" fork="true" failonerror="true"
        classname="org.jibx.binding.generator.BindGen">
      <arg value="-s"/>
      <arg value="${basedir}/src"/>
      <arg value="com.test.dto.ClassA"/>
      <arg value="com.test.dto.ClassB"/>
      <arg value="com.test.dto.ClassC"/>
    </java>
  </target>

---

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:tns="http://test.com/dto"; elementFormDefault="qualified" 
targetNamespace="http://test.com/dto/dto";>
  <xs:complexType name="classA">
    <xs:sequence/>
    <xs:attribute type="xs:boolean" name="yesNo"/>
  </xs:complexType>
  <xs:complexType name="classB">
    <xs:complexContent>
      <xs:extension base="tns:classA">
        <xs:sequence>
          <xs:element type="xs:string" name="remarks" minOccurs="0"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:element type="tns:classB" substitutionGroup="tns:classA" name="classB"/>
  <xs:complexType name="classC">
    <xs:sequence>
      <xs:element ref="tns:classA" minOccurs="0"/>
      <xs:element type="tns:classB" name="b" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element type="tns:classC" name="classC"/>
  <xs:element type="tns:classA" name="classA"/>
</xs:schema>



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to