I'm trying run BindGen on the Java classes given to me by my colleague. These
are supposed to be DTO for sending request to other applications, but they are
definitely not designed how you would normally design an XML schema. My problem
is as follow:
- 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. 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. Any pointer is appreciative.
I have provide some sample below.
Thanks,
Jack
----
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>
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users