Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2008
    Rep Power

    Default XSLT and SAX Parser

    Hi all

    I have to transform an existing XML file to a new one using a XSL file, then parse this result using a SAX parser. I did this
    Java Code:
                    File xmlFile = new File("C:\\test.xml");
    	        File xsltFile = new File("C:\\test.xsl");
     		File resultFile = new File("C:\\result.xml");
            	javax.xml.transform.Source xmlSource = new;
            	javax.xml.transform.Source xsltSource = new;
            	javax.xml.transform.Result result = new;
    	        // create an instance of TransformerFactory
        	    javax.xml.transform.TransformerFactory transFact = javax.xml.transform.TransformerFactory.newInstance();
            	javax.xml.transform.Transformer trans = transFact.newTransformer(xsltSource);
    	        trans.transform(xmlSource, result);
                    SAXParser saxParser = factory.newSAXParser();
                    saxParser.parse(result, new XMLParseHandler());
    Here XMLParseHandler extends HandlerBase. This works fine. But, I cannot create files as creating file for every run will create a few thousand files in the server every few days. I think using ByteArrayOutputStream for storing the output in memory and then converting it to ByteArrayInputStream and pass as input to parse function of SAX parser as a possible solution, but I dont know how to do it. Can you suggest a way to do it. If there is a better/easier way, I will be happy to know that too.

    Last edited by coolnfunky_raj; 07-19-2008 at 12:40 AM.

Similar Threads

  1. JSP Parser????
    By chathu03j in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 04-10-2008, 12:08 PM
  2. XSLT Transforms
    By ashleyh in forum Java Servlet
    Replies: 0
    Last Post: 03-08-2008, 05:13 PM
  3. DNS name parser 1.2.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 07-14-2007, 08:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts