• Post Reply Bookmark Topic Watch Topic
  • New Topic

XPATH Processor in java code

 
Sharang Thorat
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
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.setStylesheet(parsedStyleSheet);
try{
processor.process(new XSLTInputSource(in),new XSLTInputSource(xslfile),new XSLTResultTarget(out));
}catch (Exception e)
{
System.out.println("******************************************");
e.printStackTrace();
}

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.
regards
sharang
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!