Hi,

I encountered a serious unmarshalling bug when using
collections together with a value that has style="text".
If a collection is defined in the mapping before the
value, the value will be always empty regardless of the
xml content. (This is only true for a style="text" value,
other types such as "attribute" work).

I constructed a very simple testcase to provoke the behaviour:

-------------------------------------------------------

binding file:

<?xml version="1.0" encoding="UTF-8"?>
<binding>
  <mapping name="a" class="A">
    <collection field="coll" item-type="java.lang.String">
      <structure name="b">
        <value name="c" style="attribute"/>
      </structure>
    </collection>

    <value style="text" usage="optional" field="text"></value>
    
    <value name="name" usage="optional" field="name"
style="attribute"></value>
  </mapping>
</binding>


-------------------------------------------------------
Java class:

import java.util.ArrayList;
import java.io.FileInputStream;
import org.jibx.runtime.*;

public class A
{
  ArrayList coll = new ArrayList();
  String text;
  String name;

  public String toString()
  {
    return getClass()+" name="+name+" text="+text+" coll="+coll;
  }

  public static void main(String[] args)
  {
    try
    {
      IBindingFactory bfa = BindingDirectory.getFactory(A.class);
      IUnmarshallingContext uc = bfa.createUnmarshallingContext();
      Object o = uc.unmarshalDocument(new FileInputStream("data.xml"),
null);
      System.out.println("Could read object: "+o);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


-------------------------------------------------------

Test xml:

<a name="a">text</a>


The output is:
Could read object: class A name=a text= coll=[]


-------------------------------------------------------


This means that the text was not read. If I declare the value with
style="text" as first element within the binding it seems to work,
but this is no real solution as it leads to serious problems when
working with abstract mappings that inherit from each other. Here it
cannot be guaranteed that the value with style="text" is always the
topmost element.

Any help would be appreciated.

Best regards,
Lars

-- 
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to