There are 1 code examples for javax.xml.transform.sax.SAXSource.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: codecover-model Package: org.codecover.model

Source Code: SAXFileWriter.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Writes the given {@link TestSessionContainer} to the location specified
 * by the given {@link File}.
 * @param testSessionContainerthe {@link TestSessionContainer} to write.
 * @param filethe location, the {@link TestSessionContainer} is written to.
 * @param xmlReaderthe {@link XMLReader} to be used in creating the sax events.
 * @throws IOException
 * @throws TransformerException
 */
public static void write(TestSessionContainer testSessionContainer,File file,XMLReader xmlReader) throws IOException, TransformerException {
  FileOutputStream out=new FileOutputStream(file);
  try {
    TransformerFactory tf=TransformerFactory.newInstance();
    Transformer serializer=tf.newTransformer();
    TestSessionContainerInputSource inputSource=new TestSessionContainerInputSource(testSessionContainer);
    SAXSource source=new SAXSource(xmlReader,inputSource);
    StreamResult result=new StreamResult(out);
    serializer.setOutputProperty(OutputKeys.ENCODING,"UTF-8");
    serializer.setOutputProperty(OutputKeys.INDENT,"yes");
    serializer.transform(source,result);
    out.flush();
  }
  finally {
    out.close();
  }
}