I have been researching for the last month on what tools to use and libraries for parsing xml and performing certain business logic on the xml data in java before outputting to a flat file. I have come up with using JAXP, Xerces, JDOM and XPATH with Jaxen to traverse the JDOM tree.
Is this a suitable framework do you think before i start developing? And is there a performance issue creating a new instance of XPath every time i need a new expression or predicate to select a value from the JDOM tree?
If you're planning to use XPath for nearly everything, you may be able to reduce your dependencies on external libraries by using the built-in XPath and DOM support from Java 5 and better. Whether this is a good thing is up to you; there are other nice features in JDOM, dom4j and XOM that provide reasons to use them instead.
I wouldn't expect a significant performance impact on parsing the XPath expressions every time unless you're calling them in a loop.
I am using Java5, so i know i can use xpath and dom from JAXP but JDOM like you said has some nice features for retrieving values from the JDOM tree and Xpath and Jaxen is the libraries I need to use with JDOM.
I see that there is other tools such as dom4j and XOM but i guess you have to pick one way! its quicker i guess to use xpath expressions or xquery to look at certain xml values to output to a flat file format, i dont want to do anything too fancy so i guess ill run with this?
The virtue of XPath / XQuery is clarity of expression and reducing the amount of code you have to write, NOT speed.
I did some simple experiments comparing XPath evaluation with code using the org.w3c.dom methods, XPath was much much slower. Hardly surprising when you consider that it has to translate the path expression AND use the same dom methods.
Unless this operation has to be done many times, I would go with clarity.