The Artima Developer Community
Sponsored Link

Java Answers Forum
sorting thro' xslt

1 reply on 1 page. Most recent reply: Feb 27, 2002 9:44 AM by Anil S.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
balamurugan

Posts: 2
Nickname: nb
Registered: Feb, 2002

sorting thro' xslt Posted: Feb 26, 2002 8:43 PM
Reply to this message Reply
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


Anil S.

Posts: 13
Nickname: anil
Registered: Feb, 2002

Re: sorting thro' xslt Posted: Feb 27, 2002 9:44 AM
Reply to this message Reply
Bala-

You need to accomplish the sort in the backend,
'n when the heading is clicked make a call to
your sort method assuming you hava a jsp or a servlet
for the view.

-Anil

Flat View: This topic has 1 reply on 1 page
Topic: java.math (Mod ) Previous Topic   Next Topic Topic: Method.setAccess()

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use