When you use the <value .../> elements for the references to class MA you're saying to serialize the instances as simple text strings, not to use the structure defined by the <mapping>. You need to use a <structure .../> reference instead to make use of the <mapping> definition.

The problem is that a <mapping> normally has an associated element name, while you just want to use it as a type. The latest CVS code (just checked in) gives a workaround for this, using a <mapping abstract="true" class="myclass" ...> and references of the form <structure name="xxx" map-as="myclass" .../>. When you do this the name given on the <structure> will be used with the binding defined by the abstract <mapping>. You'll probably need to wait a few hours for the checkins to make it through to the public CVS, then get a copy and build if you want to try this out.

This is a kludge, and in beta 4 I'm taking a cleaner approach of using a <template> that corresponds to an XML Schema named type (actually goes beyond it, in that you can define <template>s below the top level while in schema named types always have to be global). This is also the basis for the xsi:type implementation.

 - Dennis

Venkatesh Prasad Ranganath wrote:

Hi,

The problem is

In terms of XSD, elements X and Y in complex type B (respectively) are of the same complex type A.
Class MA maps to the complex type A.


What would be the JiBX binding to realize this?  I have tried

<mapping name="A" class="MA">
  <value style="attribute"  name="a".../>
  <value style="attribute"  name="b".../>
  <value style="cdata"  .../>
</mapping>

<mapping name="B" class="MB">
  <value style="attribute"  .../>
   <value style="element" name="X" type="MA"/>
   <value style="element" name="Y" type="MA"/>
    ..........
</mapping>

With the above mapping, the attributes are not being set on class A with the following xml

<X a="asa" b="123">
      Text
</X>

<Y a="asa" b="123">
      Text
</Y>

Any clue what might I be doing wrong?



------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to