Mapping Java <-> XML (Castor)
Bonjour,
Je débute avec Castor, et je suis confronté au problème suivant...
Je souhaiterais parser la classe suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| public class TakingAway {
private String apheresisOfPlates;
private String apheresisOfPlatesMachineType;
private String otherApheresisOfPlatesMachineType;
private String apheresisOfPlatesAutolog;
private String plasmapheresis;
private String plasmapheresisMachineType;
private String otherPlasmapheresisMachineType;
private String plasmapheresisAutolog;
... |
Je souhaiterais obtenir l'xml suivant :
Code:
1 2 3 4 5 6 7 8 9
|
<taking-away>
<apheresis-of-plates value="on" autolog="on">
<machine-type other="test">Other</machine-type>
</apheresis-of-plates>
<plasmapheresis value="on" autolog="on">
<machine-type other="test2">Other</machine-type>
</plasmapheresis>
... |
En utilisant le mapping castor :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<n:mapping xmlns:n="http://castor.exolab.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://castor.exolab.org/ C:\JavaDev\workspaces\healthcare\castor\castortest\mapping.xsd">
<n:class name="be.medical.blood.beans.TakingAway">
<n:field name="apheresisOfPlates" type="java.lang.String">
<n:bind-xml name="value" node="attribute" location="apheresis-of-plates"/>
</n:field>
<n:field name="apheresisOfPlatesAutolog" type="java.lang.String">
<n:bind-xml name="autolog" node="attribute" location="apheresis-of-plates"/>
</n:field>
<n:field name="apheresisOfPlatesMachineType" type="java.lang.String">
<n:bind-xml name="machine-type" node="element" location="apheresis-of-plates"/>
</n:field>
<n:field name="otherApheresisOfPlatesMachineType" type="java.lang.String">
<n:bind-xml name="other" node="attribute" location="machine-type"/>
</n:field>
<n:field name="plasmapheresis" type="java.lang.String">
<n:bind-xml name="value" node="attribute" location="plasmapheresis"/>
</n:field>
<n:field name="plasmapheresisAutolog" type="java.lang.String">
<n:bind-xml name="autolog" node="attribute" location="plasmapheresis"/>
</n:field>
<n:field name="plasmapheresisMachineType" type="java.lang.String">
<n:bind-xml name="machine-type" node="element" location="plasmapheresis"/>
</n:field>
<n:field name="otherPlasmapheresisMachineType" type="java.lang.String">
<n:bind-xml name="other" node="attribute" location="machine-type"/>
</n:field>
.... |
j'obitens l'xml suivant :
Code:
1 2 3 4 5 6 7 8 9
|
<taking-away>
<apheresis-of-plates value="on" autolog="on">
<machine-type other="test" other="test2">Other</machine-type>
</apheresis-of-plates>
<plasmapheresis>
<machine-type>Other</machine-type>
</plasmapheresis>
... |
Comment faire pour que le second other soit lié au plasmapheresis ?
D'avance merci pour votre aide...