Hello,

I am working on a large Java & XML based project and we are using JibX for XML Binding. I am having a few problems doing Named abstract mappings.

We need an optional structure that we use in multiple places.

So for example we have:

<!-- Change Of Address -->
<mapping type-name="ChangeAddressOrderTypeForOrder1" class="com.work.orders.transfers.ChangeAddressOrder" abstract="true">
  <structure name="COA" field="wrslOrderType" usage="optional">
        <structure map-as="COA_Common_Type" type=" com.work.orders.transfers.COAOrderDetails"/>
        <structure name="DirectoryInformation" field="directoryInformation" map-as="type1DirectoryInformation"/>
  </structure>
  <structure name="ChangeAddressOrderTypeForOrder2" field="wbslOrderType" usage="optional">
       <structure map-as="COA_Common_Type" type="com.work.orders.transfers.COAOrderDetails"/>
       <structure name="DirectoryInformation" field="directoryInformation" map-as="type2DirectoryInformation" />
  </structure>
</mapping>

The DirectoryInformations in ChangeAddressOrderTypeForOrder1 and ChangeAddressOrderType ForOrder2 are the same java class (called com.work.orders.transfers.DirectoryInformation), but their values (annoyingly) have different values in the schema that we have to match to. So we have created two mappings for the same class (called type1DirectoryInformation and type2DirectoryInformation ). We aren't embedding them into the above mappings because they are used all over our jibx binding file.

The problem comes when we need to make the DirectoryInformations usage equal optional, like this:
        <structure name="DirectoryInformation" field="directoryInformation" map-as="type1DirectoryInformation" usage="optional"/>

When we do that, the JibX compiler works fine. But when we try to use the mapping in a java class (such as our JUnit tests) it comes up with a NullPointerException.

Has anyone had this problem before? If so have you fixed it? Or has anyone else heard of this problem before?
I imagine that a similar thing has happened before, as I imagine its quite a common structure.

If you need any more information let me know.

Thanks,

Daniel Lewis
* Analyst Programmer for Lifecycle Software Ltd (Newbury, UK): http://www.lifecycle-software.com/
* Founder & President of the Brookes Computing Society (Oxford, UK): http://www.brookescomputingsociety.org/
* Intelligent Systems & Software Engineering Student (Oxford Brookes University, Oxford, UK): http://cms.brookes.ac.uk/computing/
* Java, XML & Ruby developer for Linux/Unix, Mac & Windows

Reply via email to