xsl-list
[Top] [All Lists]

SAX for XSL Transformation

2005-02-17 11:29:26
Hello All,

I just joined the group. I'm not exactly sure how to post is a specific topic. I have a question regarding the use of SAX parser for XSL transformation. I'm not very familliar with XML technologies. I'm trying to transform a 80M file using an XSL stylesheet to an output stream. I was able to do all this when the file was only about 40Meg. Now I am having problems with out of memory errors from the JVM ,I'm assuming that the JAXP API uses a DOM object to do this transformation.

Here is the code (Which again I found on the internet)

Package com.ual.amis.frmfim;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

public class Transform {

  public Transform() {
  }

  public static void main(String[] args) {
     // If not enough args, print usage.
     if (args.length < 3) {
        System.out.println(
           "Usage: XML-File Stylesheet Output-File");
        System.exit(5);
     }

     // Get command-line args.
     File xmlFile = new File(args[0]);
     File xslFile = new File(args[1]);
     File outFile = new File(args[2]);

     // Create xsl source, input source, and result streams.
     StreamSource xslSource = new StreamSource(xslFile);
     StreamSource xmlSource = new StreamSource(xmlFile);
     StreamResult outResult = new StreamResult(outFile);

     try {
        // Get transformer factory and transformer.
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(xslSource);

        // Do transformation.
        transformer.transform(xmlSource, outResult);
     } catch(Exception ex) {
        System.out.println(ex);
        System.exit(16);
     }
  }

}

Is there a way to instruct the Transformer to use a SAX parser explicitly.

Thanks



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>