Hi!
I want MapItem value to be specific type but in two different ways, what I mean :
xml document should looks like this :
 
<myclass id="1">
  <attribute>
    <a>....</a>
    <b>....</b>
  </attribute>
  <attribute>
    <a>....</a>
    <b>....</b>
  </attribute>
  <attributeRef>
    <c>....</c>
    <item>
     <myclass id="2">
      <attribute>
        <a>....</a>
        <b>....</b>
      </attribute>
      <attributeRef>
        <c>....</c>
        <item>
         <myclass id_ref="1"/>
        </item>
      </attributeRef>
    </myclass>
   </item>
  </attributeRef>
<myclass>
 
MyClass has two maps : one with key and value of type string and second one witk key of type string and value of type MyClass but I want
to have (in xml doc) myclass defined or reference to previously defined (ex. above).
 
Mapping (right now) is :
 
<class name="MyClass" identity="id">
 <map-to xml="myclass"/>
 <field name="id" type="string"/>
   <bind-xml name="id" node="attribute">
 </field>
 <field name="attributes" collection="map" type="org.exolab.castor.mapping.MapItem">
   <bind-xml name="attribute>
     <class name="org.exolab.castor.mapping.MapItem">
       <field name="key" type="string">
         <bind-xml name="a" node="element"/>
       </field>
       <field name="value" type="string">
         <bind-xml name="b" node="element"/>
       </field>
     </class>
   </bind-xml>
 </field>
 <field name="attributeRefs" collection="map" type="org.exolab.castor.mapping.MapItem">
   <bind-xml name="attributeRef">
     <class name="org.exolab.castor.mapping.MapItem">
       <field name="key= type="string">
         <bind-xml name="c" node="element"/>
       </field>
       <field name="value" type="MyClassChoice" handler="MyClassChoice">
         <bind-xml name="item" node="element"/>
       </field>
     </class>
   </bind-xml>
 </field>
</class>
 
and here's the problem : dont know how to write MyClassChoice mapping. Maybe it's not necessary to write additional class
to handle this problem ?
I wrote like above, added handler to value field and defined mapping for MyClassChoice :
 
<class name="MyClassChoice" auto-complete="false">
    <field name="myclass" type="MyClass">
        <bind-xml name="myclass" node="element"/>
    </field>
    <field name="myrefclass" type="MyClass">
        <bind-xml name="id_ref" reference="true" node="attribute"/>
    </field>
</class>
 
 
class MyClass {
  protected Map attributes;
 
  protected Map attributeRefs;
 
  protected String id;
...
}
 
class MyClassChoice {
 
  protected MyClass myclass;
 
  protected MyClass myrefclass;
...
}
 
????
 
Handler for returning value of type MyClass (instead of MyClassChoice) but its method getValue() is not executed !!!
I also had to set unmarshaller validation to false beacuse of an execption :

1. ValidationException: unable to resolve reference: [EMAIL PROTECTED]

2. ValidationException: unable to resolve reference: [EMAIL PROTECTED]

....

With validation set to false I get object without any exception but reference attribute map in null.

Can anybody help me, suggest sth or write how can I achieve what I want ??

Thanks a lot !!!

Adrian

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to