cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Jones <...@danieljones.org>
Subject Re: help! - translating xml into html using xsl without Cocoon
Date Fri, 13 Oct 2000 20:58:19 GMT
You can use xalan:

import org.xml.sax.SAXException;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessor;
import java.io.*;

public class Transform 
{
    public static void transform (String xml, String xsl, String out)
        throws java.io.IOException, 
               java.net.MalformedURLException,
               org.xml.sax.SAXException
	{
    // Have the XSLTProcessorFactory obtain a interface to a
    // new XSLTProcessor object.
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

    // Have the XSLTProcessor processor object transform "foo.xml" to
    // System.out, using the XSLT instructions found in "foo.xsl".
    processor.process(new XSLTInputSource(new FileReader(xml)),
                      new XSLTInputSource(new FileReader(xsl)),
                      new XSLTResultTarget(new BufferedWriter (new
FileWriter (out))));
	}
    
    public static void main (String[] args) {
        try {
            transform (args[0], args[1], args[2]);
        } catch (Exception e) {}
    }
}



On Fri, 13 Oct 2000, Oppinderjeet Virdi - Customer Engineering wrote:

> ?>>2.  How do I use the XSLT processor to create a new html document specified

> >>by
> >>     a stylesheet?
> >
> >What, you mean just output it to the browser?
> 
> No I mean write a new html file, in the same directory as them xml and xsl 
> documents (i.e. not outputted to the browser)
> 
> Oppinderjeet Virdi	
> (905) 415-2898
> ovirdi@canada.sun.com
> -----------------------------
> Americas Customer Engineering
> Sun Microsystems of Canada
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 
> 


Mime
View raw message