Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java-XML

Posted on 2006-07-17
5
Medium Priority
?
231 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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

886 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