File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes below code is  correct way to write the code in generic way if we receive different xml formats Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "below code is  correct way to write the code in generic way if we receive different xml formats " Watch "below code is  correct way to write the code in generic way if we receive different xml formats " New topic
Author

below code is correct way to write the code in generic way if we receive different xml formats

subba rao
Greenhorn

Joined: Apr 24, 2008
Posts: 24
I thought of following one approach if client different EDI formats.

I will explain in detail.If user sends different EDI formats without touching java code i want to build the code in a generic way.
my intention is the code should work for all kind of EDI formats.
if client sends differents EDI formats intially i will map it only at DB side once.

for this i have created one table.in this table i will mention the EXISTING_APPLICATION_ID where this field is mapped to xml tag.we can see the values below for the 2 different EDI formats.you can also check the xml files.

if you see the java code i am getting the values from DB agaisnt field names in the application.
Xpath is used to retrive the values agaist xml tags specied in the table.

Can you please anybody tell me how is my approach?will the code suffice if client sends different type of edi formats.

can anybody light on the code on Xpath related code.will it be any performance related issues will come?
can we write more generic way better than this?

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

As long as there's a one-to-one mapping, it might be ok. To me the code seems very clunky and verbose, but that's a different issue.

Personally I think I would have implemented an interface and written an adapter between incoming formats and whatever format you end up needing it in, thus allowing wildly disparate inputs to still work. If you're just trying to allow different XML element names and everything else is identical, then keeping the possible mappings in the DB is probably fine.

It'd make me nervous, though.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1763
    
    7

You should definitely take a look at DataDirect XML Converters, if you're looking to convert standard EDI dialects to an arbitrary XML format and vice versa. If you need to support EDI that doesn't conform (entirely) to a standard dialect you can do so using the Standard Exchange Format (SEF).


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
subba rao
Greenhorn

Joined: Apr 24, 2008
Posts: 24
Thanks for the reply.first time i heard about DataDirect XML Converters.here my requirement i will get different XML formats(.xml) from the customer.even though i get different xml formats.for every xml formats it should have a FIRSTNAME,LASTENAME,'FLIGHTCODE','FLIGHTNAME' values in it.

Even though xml tag's are different but eventually all of them should be inserted into these DB columns FIRSTNAME,LASTENAME,'FLIGHTCODE','FLIGHTNAME' etc.my intension is i shouldn't change the code at java side.only one time mapping should be happened for every xml format.in what way DataDirect XML Converters will be useful in my requirement.

i hope you understood my problem.
 
Consider Paul's rocket mass heater.
 
subject: below code is correct way to write the code in generic way if we receive different xml formats