"Sin Chada, Veerpal" wrote:
>
> I have problem, how to..
>
> i have XML file below
> - <Patients>
> - <Patient pk="1234">
> <last_name>adha</last_name>
> <first_name>erpal</first_name>
> <state id="1818:1011">NY</state>
> <country id="8181:9191">USA</country>
> <race>East Indian</race>
> <address1>12 ekta avenue</address1>
> <address2>circular road</address2>
> <refering_physician_key>1912:8181</refering_physician_key>
> </Patient>
> - <Patient pk="4334">
> <last_name>Cdhaf</last_name>
> <first_name>rpadfl</first_name>
> <state id="1818:1012">NY</state>
> <country id="8181:9121">USA</country>
> <race>Indian</race>
> <address1>12 ekta avenue</address1>
> <address2>circular road</address2>
> <refering_physician_key>1912:8181</refering_physician_key>
> </Patient>
>
> </Patients>
>
> i have patient class
> public class PatientDO
> {
> private String address1;
> private String city;
> private String zip;
> private String homePhone;
> private ListDO sex; // ?
>
> private ListDO state;
> private ListDO country;
> private ListDO salutation;
> private ListDO race;
> private String first_name;
> private String last_name;
> }
>
> public class ListDO implements java.io.Serializable
> {
> public String objid;
> public String name;
> }
>
> I am unable to map ListDO to state, country ..
<field name="country" type="my.package.ListDO" container="true"/>
> I am unable to map patient because i have patient class only and patients is
> just XML strcuture to encapsulate all patients.
Just create a simple Patients class that holds your collection of
Patient objects that you can use during Marshalling/Unmarshalling:
Something like:
Patients {
private <CollectionType> _patients = null;
//-- Default constructor needed for unmarshalling
public Patients() {
_patients = new <CollectionType>
} //-- Patients
public void addPatient(Patient p) {
_patients.add<...>(p);
}
public Enumeration getPatients() {
return _patients.<...>;
} //-- getPatients
/// ... any other methods you may want ...
} //-- class: Patients
It's lightweight and can simply be discarded after you finish
unmarshalling.
--Keith
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev