* The {@link OutputStream} to write to.
*/
public void write(String path, OutputStream byteStream) {
Element element = null;
Configuration configuration = graph.getConfiguration();
FileFormat format = configuration.getFileFormat();
List<Transformation> transformations = format
.getExportTransformations();
try {
for (Transformation transformation : transformations) {
if (transformation.isXslt()) {
if (element == null) {
// writes graph
element = writeGraph();
}
XsltTransformer transformer = new XsltTransformer(
configuration.getContributorId(),
transformation.getFileName());
transformer.setParameter("path", path);
element = transformer.transformDomToDom(element);
} else {
transformation.getInstance().transform(graph, byteStream);
return;
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
if (format.getContentType().equals("text")) {
String content = element.getTextContent();
try {
byteStream.write(content.getBytes());
} catch (IOException e) {
// byte stream is a byte array output stream