Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java-XML

Posted on 2006-07-17
5
Medium Priority
?
229 Views
Last Modified: 2010-05-18
Hi All,

I have a below XML using 3 DTO objects..

<?xml version="1.0" encoding="UTF-8"?>
<OrderDetails title="OrderDetails">
 <FirmBook>?</FirmBook>
 <BlockAccMnc>T25380</BlockAccMnc>
 <QuantityOnAllocations>11000</QuantityOnAllocations>
 <Date>Mon Jul 17 14:45:11 EDT 2006</Date>
 <TradeType>CA</TradeType>
 <OrderId>*</OrderId>
 <ClientID>65475</ClientID>
 <ProductType>EQ</ProductType>
 <ExecutionPoint>*</ExecutionPoint>
 <Currency>JPY</Currency>
 <BasePrincipalOnAllocations>61000</BasePrincipalOnAllocations>
 <ExecutionChannel>*</ExecutionChannel>
 <ExecutionCountry>JPN</ExecutionCountry>
 <FiI>32216031</FiI>
 <Price>5</Price>
 <GeneralProfile>*</GeneralProfile>
 <Overrides>*</Overrides>
 <Response>*</Response>
 <Quantity>5000</Quantity>
 <AllocationDetailsList>
  <AllocationId value="53187448">
   <SubAccMnc>T20202</SubAccMnc>
   <BasePrincipalOnExecutions>33000</BasePrincipalOnExecutions>
   <QuantityOnExecutions>6000</QuantityOnExecutions>
   <AllocationId>53187448</AllocationId>
   <Price>5</Price>
   <GeneralProfile>*</GeneralProfile>
   <Overrides>*</Overrides>
   <Response>*</Response>
   <Quantity>5000</Quantity>
   <ExecutionDetailsList>
    <ExecutionId value="SBALTSE?5.0">
     <AllocationBP>0</AllocationBP>
     <AllocationID>*</AllocationID>
     <AllocationQuantity>0</AllocationQuantity>
     <ExecutionId>SBALTSE?5.0</ExecutionId>
     <Price>5</Price>
     <GeneralProfile>*</GeneralProfile>
     <Overrides>*</Overrides>
     <Response>*</Response>
     <Quantity>3000</Quantity>
    </ExecutionId>
    <ExecutionId value="SBALOSE?6.0">
     <AllocationBP>0</AllocationBP>
     <AllocationID>*</AllocationID>
     <AllocationQuantity>0</AllocationQuantity>
     <ExecutionId>SBALOSE?6.0</ExecutionId>
     <Price>6</Price>
     <GeneralProfile>*</GeneralProfile>
     <Overrides>*</Overrides>
     <Response>*</Response>
     <Quantity>3000</Quantity>
    </ExecutionId>
   </ExecutionDetailsList>
  </AllocationId>
  <AllocationId value="53187454">
   <SubAccMnc>T20202</SubAccMnc>
   <BasePrincipalOnExecutions>28000</BasePrincipalOnExecutions>
   <QuantityOnExecutions>5000</QuantityOnExecutions>
   <AllocationId>53187454</AllocationId>
   <Price>6</Price>
   <GeneralProfile>*</GeneralProfile>
   <Overrides>*</Overrides>
   <Response>*</Response>
   <Quantity>6000</Quantity>
   <ExecutionDetailsList>
    <ExecutionId value="SBALTSE?5.0">
     <AllocationBP>0</AllocationBP>
     <AllocationID>*</AllocationID>
     <AllocationQuantity>0</AllocationQuantity>
     <ExecutionId>SBALTSE?5.0</ExecutionId>
     <Price>5</Price>
     <GeneralProfile>*</GeneralProfile>
     <Overrides>*</Overrides>
     <Response>*</Response>
     <Quantity>2000</Quantity>
    </ExecutionId>
    <ExecutionId value="SBALOSE?6.0">
     <AllocationBP>0</AllocationBP>
     <AllocationID>*</AllocationID>
     <AllocationQuantity>0</AllocationQuantity>
     <ExecutionId>SBALOSE?6.0</ExecutionId>
     <Price>6</Price>
     <GeneralProfile>*</GeneralProfile>
     <Overrides>*</Overrides>
     <Response>*</Response>
     <Quantity>3000</Quantity>
    </ExecutionId>
   </ExecutionDetailsList>
  </AllocationId>
 </AllocationDetailsList>
</OrderDetails>


In Java, I have a OrderDetails Object with some attributes, AllocationDetails with some attributes and ExecutionDetails with some attributes...

OrderDetails has a list of allocationDetails and allocationDetails has list of executionDetails...


I want to use this XML -- (which comes as a log from client) .. and prepare a java file -- which can automatically populate all the objects and then call other methods...

any ideas on how can I automatically build my object hiearchy based on XML ...

I am okay to use any API's that might have come up doing this-- like hibernate or springs etc..

please help accomplishing this.

regards
0
Comment
Question by:irodov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 136 total points
ID: 17124637
0
 
LVL 10

Assisted Solution

by:mukundha_expert
mukundha_expert earned 132 total points
ID: 17127412
create classes OrderDetails, ExecutionId, AllocationId .... ( use builder pattern )

have readFromXML ( String xmlconfig ) method in all the classes, so that when you pass the Xml it should parse the XMl and populate its members.


so your OrderDetails will be

class OrderDetails
{
  String FirmBook;
String BlockAccMnc;
..
..

List executionDetailsList //list of executionID )
List allocationDetails //

readFromXml () ;

}
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 132 total points
ID: 17128474
>> any ideas on how can I automatically build my object hiearchy based on XML

Try Castor:

http://www.castor.org/ 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question