Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

uri

unix

saxon

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?

like image 600
Jubskie Avatar asked Dec 27 '22 00:12

Jubskie


1 Answers

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.

like image 154
Jubskie Avatar answered Mar 02 '23 01:03

Jubskie