Hi Dennis,

well, I tried to use a member of type Object in my class. When I tried to
compile, Jibx complained about an "Error: No ID definitions for compatible
type". Hence I thought that it is not possible to use Object as a refereced
object due to the fact that there is no mapping for it. Here is what binding an
d class looked like:

--- class ---
[...service.class, custumer.class...]
[...]
public class Ref
{
  protected Object referecedObject;
[...]
}
-------------
--- binding ---
[...]
<mapping name="SERVICE" class="de.hsc.jibx.Service">
    <value style="attribute" name="ID" field="id" usage="required" ident="def"/>
</mapping>
<mapping name="CUSTOMER" class="de.hsc.jibx.Customer">
    <value style="attribute" name="ID" field="id" usage="required" ident="def"/>
</mapping>
<mapping name="REF" class="de.hsc.jibx.Ref">
    <value style="attribute" name="LINK" field="link" usage="required" 
ident="ref"/>
</mapping>
[...]
---------------

When I compiled -> "Error: No ID definitions for compatible type".

Well, maybe I am just not smart enough (no joke - I mean it in a technical
sense). I came up with the idea to use an abstract class "RefObj" which is
inherited from all referencable objects. Binding and class now looks like that:

--- class ---
[...service.class, custumer.class... which extends RefObj now]
[...]
public class Ref
{
  protected RefObj referecedObject;
[...]
}
--- binding ---
[...]
<mapping class="de.hsc.jibx.RefObj" abstract="true">
 <value name="ID" field="id" style="attribute" ident="def"/>
</mapping>
<mapping name="SERVICE" class="de.hsc.jibx.Service" 
extends="de.hsc.jibx.RefObj">
 <structure map-as="de.hsc.jibx.RefObj"/>
</mapping>
<mapping name="CUSTOMER" class="de.hsc.jibx.Customer" 
extends="de.hsc.jibx.RefObj">
 <structure map-as="de.hsc.jibx.RefObj"/>
</mapping>
<mapping name="REF" class="de.hsc.jibx.Ref">
    <value style="attribute" name="LINK" field="link" usage="required" 
ident="ref"/>
</mapping>
[...]
---------------

That works fine so far.

Thanks.
- Holger



Dennis Sosnoski schrieb:
> Hi Holger,
> 
> Maybe I'm missing something, but I don't see why using java.lang.Object 
> wouldn't work for this case. ID/IDREF are an untyped linkage mechanism, 
> so there shouldn't be any constraints on using the same form of 
> references to different types of elements.
> 
>   - Dennis
> 
> Dennis M. Sosnoski
> SOA and Web Services in Java
> Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
> 
> 
> 
> Holger Schultz wrote:
>> Hi all,
>>
>> i've run into a little problem here. Maybe someone has a solution or an idea 
>> how
>> it could be solve.
>>
>> Within an XML-Document there is an element which references another element. 
>> If
>> the referenced element is always of the same type I've got no problem by 
>> using
>> ID/IDREF.
>>
>> Unfortunatelly in this case there is no way to tell what kind of element 
>> will be
>> referenced. Example:
>>
>> -------------------------------------
>> <SERVICES NAME="S1">
>>   <SERVICE ID="SID1">
>>     <DATA>Wrzlprmpf</DATA>
>>   </SERVICE>
>> </SERVICES >
>> <SERVICES NAME="S2">
>>   <REF IDREF="SID1"/>
>> </SERVICES >
>> <CUSTOMERS NAME="C1">
>>   <CUSTOMER ID="CID1"/>
>>     <NAME>Holger</NAME>
>>   </CUSTOMER>
>> </CUSTOMERS>
>> <CUSTOMERS NAME="C2">
>>   <REF IDREF="SID1"/>
>> </CUSTOMERS>
>> -------------------------------------
>>
>> As you can see element "REF" can reference a "SERVICE" as well as a 
>> "CUSTOMER".
>> So it is impossible to tell what kind of element will be referenced. As far 
>> as I
>> figured it out an ID/IDREF solution can't be used here.
>>
>> Is there any way to tell "REF" and it's representing class that the 
>> referenced
>> object can be of any kind. I tried java.lang.Object but after a failed 
>> attempt
>> of compiling it, it was quite obvious to me why this couldn't work (shame on 
>> me).
>>
>> So, any suggestions or (even better) solutions will be highly appreciated.
>>
>> @Dennis: Thank you so much for your great work and effort here.
>>
>> regards,
>> Holger
>>   
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> jibx-users mailing list
>> jibx-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jibx-users
>>   
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
> 

-- 
Mit freundlichem Gruß / Kind Regards
Holger Schultz
IT-Berater

# HMS IT-Service Holger Schultz
# Weinbergstraße 26 - 73269 Hochdorf, BaWü - Germany
# Tel.  : +49.7153.60.80.90-1
# Fax   : +49.7153.60.80.90-9
# Mobil : +49.177.388.0137
# E-Mail: [EMAIL PROTECTED]

# Sitz des Unternehmens: Hochdorf
# Geschäftsführer: Holger Schultz

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to