Saxon and setBaseOutputURI resulting in "URI has an authority component" error

Jubskie picture Jubskie · Jul 16, 2013 · Viewed 8.8k times · Source

I'm using saxon to create 5 html files from 1 xml file. Whenever I run the code windows, it runs smoothly and creates all the necessary files. However, when I run the code in unix, it resulted in this error:

Failed to create output file file:/output1.html:   Permission denied

Searching in stackoverflow, I learned it was trying to write into the root directory, which brought me to try setBaseOutputURI().

I'm trying to make saxon output the html files into /foo/biz/html_out, so I wrote this code:

String filePathUri = "file://foo/biz/html_out/";
xsltTransformer.setBaseOutputURI(filePathUri);

The error now reads

net.sf.saxon.s9api.SaxonApiException: Cannot write to URI file://foo/output1.html (URI has an authority component)
    at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:454)

My questions are:

  1. Did I arrive at the correct conclusion that I have to use setBaseOutputURI?

  2. Am I writing the URI wrong?

  3. Is there any else I should try, considering the code works fine in windows?

Answer

Jubskie picture Jubskie · Jul 17, 2013

Found the answer!

I had to use "file:///foo/biz/html_out" as the URI. The extra slash made the rest of the string the text the path.