Hi,

Question about fairly advanced JiBX usage.

I have three projects in different JAR files (names somewhat obfuscated):
  * CAI3G core
  * CAI3G APPLES
  * CAI3G ORANGES

CAI3G core defines XML "envelope", sample:
<cai3g:Create xmlns:cai3g="http://schemas.company.com/cai3g";>
   <cai3g:Object>
     <!-- in here we can use some abstract types -->
   </cai3g:Object>
</cai3g:Create>

Inside that "envelope" can be some XML element that core project is not 
aware of (declares in schema either ANY element or substitution group - 
but I guess this is not important for JiBX).

This envelope corresponds to Java class:
public class Create {
   public Object object;
}

APPLES and ORANGES use core project and fill in the contents of the 
"envelope" (Create class) and hand this object to code in core project 
which then is supposed to marshal and unmarshal the full graph.
The end-result XML should look something like this:

APPLE create:
<cai3g:Create xmlns:cai3g="http://schemas.company.com/cai3g";>
   <cai3g:Object>
   <Apple xmlns="http://schemas.company.com/apples";>
     <Color>Red</Color>
     <Taste>Delicious</Taste>
   </Apple>
   </cai3g:Object>
</cai3g:Create>

ORANGE create:
<cai3g:Create xmlns:cai3g="http://schemas.company.com/cai3g";>
   <cai3g:Object>
   <Orange xmlns="http://schemas.company.com/orange";>
     <Size>Large</Size>
     <Juicy>True</Juicy>
   </Orange>
   </cai3g:Object>
</cai3g:Create>

How do I define JiBX binding file so that this case is handled 
correctly? I browsed the docs, but couldn't find any obvious answer.

I imagine that it could work like this:
  * in core binding.xml I state that particular XML element can contain 
ANY child elements and these should be parsed with root level mappings
  * in APPLES and ORANGES projects I define bindings with root level 
mappings for concrete wrapped types (Apple and Orange).
  * I make these three different binding factories aware of each other

How do I achieve something like that? Is it possible at all? I just 
scrapped XmlBeans in favor of JiBX because this kind of setup seemed 
impossible to achieve with XmlBeans. Please tell me it is possible with 
JiBX.

;-)

As a starter, I tried (in core):
        <mapping name="Create" class="Create">
                <value name="Object" field="object"/>
        </mapping>

This gives me the following error in Eclipse JiBX plugin:
Error: Need deserializer or constructor from string for type 
java.lang.Object; on value element at (line 44, col 36, in binding.xml)

Any pointers appreciated.

Rgds,
Neeme


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to