I know that I can create xml
files programmatically by using DOM
api in java like the following:
DocumentBuilderFactory do
Since XSLT it's XML too, you can simply use the same strategy:
...
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement("xsl:stylesheet");
// adding attributes like namespaces etc...
document.appendChild(rootElement);
Element em = document.createElement("xsl:template");
em.setAttribute("match", "/");
and so on...
But it's not very elegant. You should use a library or a framework instead, you should easily find one googling around.