Hi Joachim,

It's not clear from this email what you're actually doing with the mapping. The getIdValue() method is only used when marshalling, so if you're only unmarshalling the existing document you won't see this called. What are you seeing as the result of the unmarshalling?

 - Dennis

Joachim Kleb wrote:

Hi all,

I´ve tried to get the IdRefMapperBase (IdDefRefMapperBase) samples to run, but I wasn´t very successful.
Maybe somebody can give me a clue why.

The problem is:
The code will be executed, but it seems like the "protected String getIdValue(Object item)" method is never called. The sysout in this method is never called, in opposition to the sysout in the constructor term.


My "test" conditions are likely the same as in the shipped example files.
But to play safe I attached my used files below.

---------binding--------
<binding>
  <mapping name="names" class="test.NameArray">
    <collection field="m_references" usage="optional">
      <structure name="name" marshaller="test.NameArray$DefRefMapper"
          unmarshaller="test.NameArray$DefRefMapper"/>
    </collection>
  </mapping>
  <mapping name="name" class="test.Name">
    <value name="id" style="attribute" field="m_id" ident="def"/>
    <value name="first-name" field="m_first"/>
    <value name="last-name" field="m_last"/>
  </mapping>
</binding>
-----------name.xml-------
<names>
<name id="c0001"><first-name>Tom</first-name><last-name>Sawyer</last-name></name> <name id="c0002"><first-name>George</first-name><last-name>Smith</last-name></name> <name id="c0003"><first-name>Adam</first-name><last-name>Smith</last-name></name>
    <name ref="c0001"/>
    <name ref="c0002"/>
</names>
----------NameArray---------
public class NameArray
{
    public Object[] m_names;
    public ArrayList m_references;

    private static class DefRefMapper extends IdDefRefMapperBase
    {
        public DefRefMapper(String uri, int index, String name) {
            super(uri, index, name);
        // this one will be called
System.out.println("DefRefMapper: uri: "+uri+" index: "+index+" name: "+name);
        }

        protected String getIdValue(Object item) {
        // this one not
            System.out.println("DefRefMapper: "+item);
            return "test";
        }
    }
}
-----------------------------
I used the actual version of jibx: jibx-1.0RC0.



-------------------------------------------------------
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_idt77&alloc_id492&op=click
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to