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.
The moose likes XML and Related Technologies and the fly likes XPATH Processor in java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPATH Processor in java code " Watch "XPATH Processor in java code " New topic

XPATH Processor in java code

Sharang Thorat

Joined: Dec 07, 2000
Posts: 21
i have an xml which i want to sort on certain elements
as specified by user GUI.
i intend to follow following steps

1. convert xml to another xml using XPATH processor
here sorting crieterion from user will be applied.
2. apply xslt on that xml and display

i could achive the step 2 in my code

File xmlfile = new File(file_path.concat("\\temp.xml"));
File stylesheet = new File(file_path.concat("\\rsdstylesheet.xsl"));

FileInputStream in = new FileInputStream(xmlfile);
FileInputStream xslfile = new FileInputStream(stylesheet);

XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
//StylesheetRoot parsedStyleSheet = null;

//parsedStyleSheet = processor.processStylesheet( new XSLTInputSource( xslfile ) );
processor.process(new XSLTInputSource(in),new XSLTInputSource(xslfile),new XSLTResultTarget(out));
}catch (Exception e)

but how to cheive step one. How to apply the user selected crieterion for sorting on the xml and using XPath convert it
to anohter xml. i know how to do it on command line
using org.apache.xalan.xpath.Process class but is there any implementation for that class to call it through the programme
like XSLTProcessor class.
I agree. Here's the link:
subject: XPATH Processor in java code
It's not a secret anymore!