Thread Safety

  TransformerFactory xformFactory = TransformerFactory.newInstance();
  Source xsl = new StreamSource("stylesheet.xsl");
  Templates templates = xformFactory.newTemplates(xsl);
  ...
while (true) {
  InputStream  in   = getNextDocument();
  OutputStream out  = getNextTarget();
  Source request    = new StreamSource(in);
  Result response   = new StreamResult(out);
  Transformer transformer = templates.newTransformer();
  transformer.transform(request, response);
}

Previous | Next | Top | Cafe con Leche

Copyright 2000-2003 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified January 12, 2003