• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

XPATH Processor in java code

 
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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!