This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a xslt file I used following java code to transform it .I want to retrieve each node in XSLT as an object or collection of objects and pass them as parameters to other Java code. Is it possible to retrieve values without passing them to stream or Is there any other alternative way to do that
I don't want to use DOM either. It's annoying to write and easy to get wrong. But when it's the best tool for the job at hand then I use it.
But if you have some real-life reason for not using DOM, then you could parse the original XML using a SAX parser and write a ContentHandler to capture the data.
Or if somebody says you have to use the output of that transformation (maybe some manager who doesn't understand things) then you could send its output to a StringWriter and parse the resulting string to extract the data.
Why not try using xpath javax.xml.xpath package in java 1.5 or xalan.jar for earlier versions of java
I guess since you know xslt you must know xpath so the learning curve will be less
I've just made use of xpath i my project and you wont beleive how much coding I have avoided using xpath
just my 2 cents
xpath uses DOM under its hood I guess
Joined: Jan 03, 2002
Thanks for your quick response.
Paul :I have also written SAX Parser.But I wanted to try to retrieve values from XSLT transformation too sothat, I can have a common class to transform any number of XSLT files.
Rajagopal :I have written XPATH using Java1.5 but the problem with that is I couldn't generalize the elements(If I have more than one set of same type). If there is a way to retrive collections using that without passing specific XPATH expression for every element please let me know.
Joined: Nov 26, 2004
Originally posted by bhargavi kakarala: Rajagopal :I have written XPATH using Java1.5 but the problem with that is I couldn't generalize the elements(If I have more than one set of same type). If there is a way to retrive collections using that without passing specific XPATH expression for every element please let me know.
I have not worked with the jdk 1.5 version of xpath because I am stuk with jdk 1.3 and xalan but I think the