The problem is in the constructor of StreamResult
, you are passing null
there. And this is what it expects
public StreamResult(String systemId)
Construct a StreamResult from a URL.
Parameters:
systemId - Must be a String that conforms to the URI syntax.
You should use another constructor. This should work, if your xml and xsl is correct (and t contains your xml). Note that StringBufferInputStream
is deprecated but works as a quick-and-dirty solution):
TransformerFactory factory = TransformerFactory.newInstance();
//File object with path to your xsl file
StreamSource xslStream = new StreamSource(new File("C:\\xsl\\rok.xsl"));
Transformer transformer = factory.newTransformer(xslStream);
//Read xml from string
StreamSource in = new StreamSource(new StringBufferInputStream(t));
//Prints to stdout
StreamResult out = new StreamResult(System.out);