What is the best way to implement an application in Java that converts xml in one format into another? [on hold]


What is the best way to implement an application in Java that converts xml in one format into another? [on hold]



I have to write an application that processes a large amount of xml files and transforms xml defined by xsd1 to xml defined by xsd2.
The xsd1 file will change frequently during the project.
The single xml file is at most 200Kb.
There will be a lot of business logic in a transformation.
I would like to be as close as possible to the Java standard libraries.



What would be the best approach to implement this application in terms of the xml file processing?



Should I use in this case DOM,SAX,JAXB,XPATH or something else?



To be more precise the only change that might happen is addition of the anonymous inner elements in the xsd, so that there will be for example multiple times an anonymous inner element item defined, which results in Item1,Item2,...,ItemN classes generated. When the new anonymous Item3 is added then Item1 becomes Item3 and every occurrence in code of Item1 has to be replaced with Item3.



Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.





Have you considered using XSLT?
– beny23
2 days ago





Yes I have considered using XSLT, however as there will be a lot of business logic involved during transformation I prefer to have it implemented in Java than in XSLT.
– BlueLettuce16
2 days ago





You should certainly use XSLT for this, supplemented by your own Java business-logic functions.
– EJP
2 days ago





@BlueLettuce16 You can implement your buiseness logic in XSLT. You can even call Java from XSLT, that's pretty normal.
– lexicore
2 days ago





XSLT is the standard and most effective way to transform from XML to XML, yes, even with business logic being involved with the transformation. However, this question should be closed as primarily opinion-based because it is the sort that tends to lead to uninformed touting of languages/approaches based upon familiarity and favoritism rather than objective explanations.
– kjhughes
2 days ago





1 Answer
1



XSLT is a language for transforming XML documents into other XML documents.



Standard thing.



Very well supported on the Java plattform.



Excellent third-party libraries like Saxon are available. If you're XML Schema driven, Saxon is pretty good with XML Schema-aware processing.





He wrote that "There will be a lot of business logic in a transformation". In such a case, I am not sure that XSLT is the best choice, from the readability and maintainability point-of-view.
– Yoav Gur
2 days ago






@YoavGur I see no problem implementing the business logic in XSLT.
– lexicore
2 days ago





I had the "pleasure" of seeing and maintaining such XSLT's. It was a nightmare. I wish it was structured java code instead.
– Yoav Gur
2 days ago





@YoavGur I personally have positive experience with XSLT. Yes, with complex filled-with-business-logic XSLT, also calling Java routines. Saxon does wonders.
– lexicore
2 days ago





@YoavGur: Sorry about your bad experience. You should have sought help. Professionals who know XSLT well swear by its effectiveness.
– kjhughes
2 days ago

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV