final OutputStream outputStream = bundle.createEntry(fileName, "text/xml");
final DefaultTagDescription tagDescription = new DefaultTagDescription
(ClassicEngineBoot.getInstance().getGlobalConfig(), KettleDataFactoryModule.TAG_DEF_PREFIX);
final XmlWriter xmlWriter = new XmlWriter(new OutputStreamWriter(outputStream, "UTF-8"), tagDescription, " ", "\n");
final KettleDataFactory kettleDataFactory = (KettleDataFactory) dataFactory;
final AttributeList rootAttrs = new AttributeList();
rootAttrs.addNamespaceDeclaration("data", KettleDataFactoryModule.NAMESPACE);
xmlWriter.writeTag(KettleDataFactoryModule.NAMESPACE, "kettle-datasource", rootAttrs, XmlWriter.OPEN);
final String[] queryNames = kettleDataFactory.getQueryNames();
for (int i = 0; i < queryNames.length; i++)
{
final String queryName = queryNames[i];
final KettleTransformationProducer prod = kettleDataFactory.getQuery(queryName);
final TransformationProducerWriteHandler handler = lookupWriteHandler(prod);
handler.writeKettleRepositoryProducer(bundle, fileName, xmlWriter, queryName, prod);
}
xmlWriter.writeCloseTag();
xmlWriter.close();