*/
protected byte[] serialize(Node exportRootNode, boolean isSystemView, boolean isStream) throws IOException,
RepositoryException, SAXException, TransformerConfigurationException
{
ExtendedSession extendedSession = (ExtendedSession)exportRootNode.getSession();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
if (isSystemView)
{
if (isStream)
{
extendedSession.exportSystemView(exportRootNode.getPath(), outStream, false, false);
}
else
{
SAXTransformerFactory saxFact = (SAXTransformerFactory)TransformerFactory.newInstance();
TransformerHandler handler = saxFact.newTransformerHandler();
handler.setResult(new StreamResult(outStream));
extendedSession.exportSystemView(exportRootNode.getPath(), handler, false, false);
}
}
else
{
if (isStream)
{
extendedSession.exportDocumentView(exportRootNode.getPath(), outStream, false, false);
}
else
{
SAXTransformerFactory saxFact = (SAXTransformerFactory)TransformerFactory.newInstance();
TransformerHandler handler = saxFact.newTransformerHandler();
handler.setResult(new StreamResult(outStream));
extendedSession.exportDocumentView(exportRootNode.getPath(), handler, false, false);
}
}
outStream.close();
return outStream.toByteArray();
}