TRaX Code Example

public class TRaXample {
	
  public static void main( String[] args) { 
    try {
      Source input = new StreamSource( "input.xml");
      TransformerFactory factory = TransformerFactory.newInstance();
      
      Source style = new StreamSource( "stylesheet.xsl");
      Transformer transformer = xformFactory.newTransformer( style);
      transformer.setParameter( "debug", "true()");
      
      Result outputDocument = new StreamResult( output.txt);
      stylesheet.transform( inputDocument, outputDocument);
    } catch ( TransformerConfigurationException e) {
      e.printStacktrace(); 
    } catch ( TransformerException e) {
      e.printStacktrace(); 
    }
  }
}