Solved

Java-XML

Posted on 2006-07-17
5
221 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 34 total points
ID: 17124637
0
 
LVL 10

Assisted Solution

by:mukundha_expert
mukundha_expert earned 33 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:mayankeagle
mayankeagle earned 33 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now