if (StringUtils.isNotBlank(modelUri))
{
final URL modelUrl = new URL(modelUri);
if (xsltTransformations != null && xsltTransformations.length > 0)
{
Source modelSource = new StreamSource(modelUrl.openStream());
final List xslts = Arrays.asList(xsltTransformations);
final TransformerFactory factory = TransformerFactory.newInstance();
final TransformerURIResolver resolver = new TransformerURIResolver();
factory.setURIResolver(resolver);
for (final Iterator xsltIterator = xslts.iterator(); xsltIterator.hasNext();)
{
final Transformation transformation = (Transformation)xsltIterator.next();
final URL xslt = new URL(transformation.getUri());
resolver.setLocation(xslt);
if (xslt != null)
{
AndroMDALogger.info("Applying transformation --> '" + xslt + "'");
final Source xsltSource = new StreamSource(xslt.openStream());
final javax.xml.transform.Transformer transformer = factory.newTransformer(xsltSource);
final ByteArrayOutputStream output = new ByteArrayOutputStream();
final Result result = new StreamResult(output);
transformer.transform(modelSource, result);
final byte[] outputResult = output.toByteArray();
stream = new ByteArrayInputStream(outputResult);
// if we have an output location specified, write the result
final String outputLocation = transformation.getOutputLocation();
if (StringUtils.isNotBlank(outputLocation))
{
final File fileOutput = new File(outputLocation);
final File parent = fileOutput.getParentFile();
if (parent != null)
{
parent.mkdirs();
}
FileOutputStream outputStream = new FileOutputStream(fileOutput);
AndroMDALogger.info("Transformation output: '" + outputLocation + "'");
outputStream.write(outputResult);
outputStream.flush();
outputStream.close();
outputStream = null;
}
if (xsltIterator.hasNext())
{
modelSource = new StreamSource(stream);
}
}
}
}
else if (modelUrl != null)