balamurugan
Posts: 2
Nickname: nb
Registered: Feb, 2002
sorting thro' xslt
Posted: Feb 26, 2002 8:43 PM
Advertisement
hai, i am bala. I had generated one html table which contains the fields fetched from the mysql database. For generating the html i had used one of the techniques in xslt that using Stream source.. I had sorted the table on loading time... But i have to do sorting when a particular column heading is clicked,based on that particular column the overall table should be sorted.... Is there any technique available for that... Please help me in that..... I want it immediately..... Here is my xsl coding: ********************** import java.io.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; /** * Transform an input xml file into another format using * an xsl stylesheet. Output is saved to file output. */ public class xslt { public xslt() { } public void transform(File input, File stylesheet, File output) { try { FileInputStream fis = new FileInputStream(stylesheet); byte[] b = new byte[fis.available()]; fis.read(b); System.out.println("this is the content of the file " + new String(b)); StreamSource inputstream = new StreamSource(input); StreamSource stylesheetstream = new StreamSource(stylesheet); System.out.println("the transformer object is " + stylesheetstream); StringWriter stringwriter = new StringWriter(); TransformerFactory transformerfactory = TransformerFactory.newInstance(); System.out.println("this is from the method"); Transformer transformer = null; try { transformer = transformerfactory.newTransformer(stylesheetstream); } catch(Exception e) { System.out.println("this is in the exception" + e); } System.out.println("finally i entered"); transformer.transform(inputstream, new StreamResult(stringwriter)); FileWriter fw = new FileWriter(output); fw.write(stringwriter.toString()); fw.close(); } catch (TransformerConfigurationException tce) { System.err.println("TransformerConfigurationException: " + tce.getMessage()); } catch (TransformerException te) { System.err.println("TransformerException: " + te.getMessage()); } catch (IOException ioe) { System.err.println("IOException: " + ioe.getMessage()); } catch (Exception exception) { System.err.println("Exception: " + exception); } finally { } } public static void main(String args[])throws Exception { xslt obj = new xslt(); File xml = new File("domain.xml"); File xsl = new File("main2.xsl"); File xml1 = new File("domainReport.html"); obj.transform(xml, xsl, xml1); } } Thanks for your help bala