Hi Yana, This is definitely a bug in the code generation. You should get separate classes for text01 and text02 by default, since these are different global element definitions in you schema, but the binding should not be adding the extra level of element name for the text01 mapping.
I'm going to be cleaning up as many bugs as possible over the next week in order to finally get out a 1.2.2 release, and I should be able to get this fixed as part of the clean up. I've created a Jira to track the issue: http://jira.codehaus.org/browse/JIBX-309 - Dennis Dennis M. Sosnoski XML and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Yana Panchenko wrote: > Hi, > I've localized my problem and also found a solution for it. But still > the question is that the default behavior of binding generation is a > bit strange in this particular case. I'll explain the problem with a > more clear example (although not realistic) this time. > > For example generating code and binding from the schema: > > <?xml version="1.0" encoding="UTF-8"?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns="http://uni.tuebingen.de/sfs/testexample" > elementFormDefault="qualified" > targetNamespace="http://uni.tuebingen.de/sfs/testexample"> > <xs:element name="example"> > <xs:complexType> > <xs:choice maxOccurs="unbounded"> > <xs:element ref="text01"/> > <xs:element ref="text02"/> > </xs:choice> > <xs:attribute name="lang" type="xs:string"/> > <xs:attribute name="source" type="xs:anyURI"/> > </xs:complexType> > </xs:element> > <xs:element name="text01"> > <xs:complexType> > <xs:simpleContent> > <xs:extension base="xs:string"> > </xs:extension> > </xs:simpleContent> > </xs:complexType> > </xs:element> > <xs:element name="text02"> > <xs:complexType> > <xs:simpleContent> > <xs:extension base="xs:string"> > <xs:attribute name="ID" type="xs:ID"/> > </xs:extension> > </xs:simpleContent> > </xs:complexType> > </xs:element> > </xs:schema> > > > would generate binding with two different mapping scenarios for > <text01> and <text02> although these elements differ only in attribute > specification: > > <binding xmlns:tns="http://uni.tuebingen.de/sfs/testexample" > name="binding" package="de.tuebingen.uni.sfs.testexample"> > <namespace uri="http://uni.tuebingen.de/sfs/testexample" > default="elements"/> > <mapping class="de.tuebingen.uni.sfs.testexample.Example" > name="example"> > <collection get-method="getChoices" set-method="setChoices" > create-type="java.util.ArrayList"> > <structure > type="de.tuebingen.uni.sfs.testexample.Example$Choice" ordered="false" > choice="true"> > <structure type="de.tuebingen.uni.sfs.testexample.Text01" > test-method="ifText01" get-method="getText01" set-method="setText01" > usage="optional"/> > <structure type="de.tuebingen.uni.sfs.testexample.Text02" > test-method="ifText02" get-method="getText02" set-method="setText02" > usage="optional"/> > </structure> > </collection> > <value style="attribute" name="lang" get-method="getLang" > set-method="setLang" usage="optional"/> > <value style="attribute" name="source" get-method="getSource" > set-method="setSource" usage="optional"/> > </mapping> > <mapping class="de.tuebingen.uni.sfs.testexample.Text01" name="text01"> > <value style="element" name="text01" get-method="getText01" > set-method="setText01"/> > </mapping> > <mapping class="de.tuebingen.uni.sfs.testexample.Text02" name="text02"> > <value style="text" get-method="getString" set-method="setString"/> > <value style="attribute" name="ID" get-method="getID" > set-method="setID" usage="optional"/> > </mapping> > </binding> > > > The result of such a binding is that the file below couldn't be > unmarshalled: > > <?xml version="1.0" encoding="UTF-8"?> > <example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://uni.tuebingen.de/sfs/testexample"> > <text01>Ich bin im Sande eingeschlafen.</text01> > <text02>Ich bin im Sande eingeschlafen.</text02> > </example> > > > Because the binding expects the file like this: > > <?xml version="1.0" encoding="UTF-8"?> > <example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://uni.tuebingen.de/sfs/testexample"> > <text01> > <text01>Ich bin im Sande eingeschlafen.</text01></text01> > <text02>Ich bin im Sande eingeschlafen.</text02> > </example> > > The solution I found for it is to change the mapping for <text01> > manually, so that it looks similar to the mapping for <text02>, i.e. > I've changed it to: > > <mapping class="de.tuebingen.uni.sfs.testexample.Text01" name="text01"> > <!--<value style="element" name="text01" get-method="getText01" > set-method="setText01"/>--> > <value style="text" get-method="getText01" set-method="setText01"/> > </mapping> > > Now the file will be marshalled and unmarshalled correctly: > > <?xml version="1.0" encoding="UTF-8"?> > <example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://uni.tuebingen.de/sfs/testexample"> > <text01>Ich bin im Sande eingeschlafen.</text01> > <text02>Ich bin im Sande eingeschlafen.</text02> > </example> > > I think the default behavior is wrong. Changing binding file manually > each time I regenerate it, it is not very convenient, so is it > possible to customize this? How? > > Kind regards, > Yana > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------------------------------ _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users