Bruno Verachten wrote:
>
> Hi,
>
> I'm using xalan-j_2_2_D9, and I get this error when I use the following
> code:
> ---------
> java.net.UnknownServiceException: protocol doesn't support output
> at java.net.URLConnection.getOutputStream(Unknown Source)
> at
>
>org.apache.xalan.xsltc.trax.TransformerImpl.getOutputHandler(TransformerImpl.java:232)
> at
> org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:166)
> at
> net.atos.mm.fwk.xml.bench.xsl.BenchXSLTC.fromFileToFile(BenchXSLTC.java:228)
> at
> net.atos.mm.fwk.xml.bench.xsl.BenchXSLTC.runTest(BenchXSLTC.java:140)
> at net.atos.mm.fwk.xml.bench.xsl.BenchBase.run(BenchBase.java:245)
> ----------
> private void fromFileToFile(String sourceID, String xslID)
> throws TransformerException,
> TransformerConfigurationException {
>
> // Create a transform factory instance.
> TransformerFactory tfactory =
> TransformerFactory.newInstance();
>
> // Create a transformer for the stylesheet.
> Transformer transformer =
> tfactory.newTransformer(new StreamSource(xslID));
>
> // Transform the source XML to System.out.
> try {
> transformer.transform(new StreamSource(sourceID),
> new
> StreamResult(new File("fromFileToFile.out").toURL().toString()));
> } catch (java.net.MalformedURLException e) {
> }
> }
>
> What did I miss?
Have a look at the string created by
new File("fromFileToFile.out").toURL().toString()
It probably looks funny. In any event, the easiest way to do this is to
just supply the File as the argument to StreamResult:
... new StreamResult(new File("fromFileToFile.out"))
Gary