I've switched to Stanimir's solution of letting Java handle this; I
think it really is the better answer unless we want to really
reimplement toUri() in the test framework.
There are a few other failures being reported in the conf.xsltc
(compiled stylesheet) tests. I haven't checked whether they are present
on Windows as well. They appear to be issues of HTML parsing, so it's
possible that I don't have the expected version of tidy; what I'm seeing
in my xalan-test/tools directory is jtidy-r938.jar, which reports it was
released on 2009-12-01. I'll try to take a look at those over the weekend.
On 3/10/2023 6:06 PM, Joseph Kessselman wrote:
Actually... Let me look at the official URI syntax. It is possible
that the third / is officially the delimiter at the end of the
authority component and the path is NOT expected to start with /. In
which case, while this works, the Officially Correct solution would
appear to instead be to always insert the URL_SEP but strip leading
'/' off user.dir.
BUT...
As Stanimir points out, it may make more sense to just delegate this
to Java and call
baseURL = new java.io.File(System.getProperty("user.dir"))
.toPath().toUri().toString();
rather than get into hand-coding this at all. Hopefully, a modern
Java's implementation is already doing the Right Thing for this
relatively simple operation.
Comments?
On 3/10/2023 5:51 PM, Joseph Kessselman wrote:
Ahh. That explains why it works on Windows -- the Windows user.dir
includes the drive letter, so even as an absolute path it doesn't
start with /.
However on Linux, where the absolute path does start with / rather
than C:\, we are getting //// where /// is expected.
Simplest fix might be to not insert URL_SEP after FILE_SCHEME if
user.dir starts with ''/'.
Or, more clearly, to insert URL_SEP only if user.dir does NOT start
with '/', since really Windows should be considered the special case
here.
I'll run a santity-check on it to make sure it doesn't affect
anything it shouldn't, but I think the latter is what I'm proposing.
Oh well. At least the actual application code does it correctly in
both environments. It might even be calling java.nio under the
covers; I haven't checked. Perhaps the test should too, rather than
reinvent this special case.
Proposed SystemIDResolverAPITest.testCase1() code follows. Note that
the previous commented-out OS-dependent workaround, which would
follow this, can be discarded.
public boolean testCase1()
{
reporter.testCaseInit("Using our data set of URLs, try
various resolver calls");
try
{
String prevUserDir = System.getProperty("user.dir");
String baseURL = prevUserDir.replace('\\', '/');
if (null == baseURL)
baseURL = "";
// To turn a posix user.dir into a filesystem URL,
// prefix it with FILE_SCHEME (normally with a blank
authority
// component) and follow it with URL_SEP to ensure it is
taken as
// a directory.
//
// HOWEVER: On Windows, where absolute paths begin with a
drive letter rather
// than the root-directory URL_SEP, Xalan is expected to
insert a URL_SEP
// between the scheme and user.dir, so the baseURI always
starts with
// "file:///". I believe that will be a general behavior
when the first
// character of the user.dir path is not / (after \ to /
conversion), and have
// implemented the test that way.
//
if(baseURL.length()>0 && baseURL.charAt(0)!='/')
baseURL="/"+baseURL;
baseURL = FILE_SCHEME + baseURL + URL_SEP;
// ... and so on
On 3/10/2023 2:16 AM, Stanimir Stamenkov wrote:
Thu, 9 Mar 2023 23:23:01 -0500, /Joseph Kessselman/:
SystemIDResolverAPITest.java, line 121:
baseURL = FILE_SCHEME + URL_SEP + baseURL + URL_SEP;
FILE_SCHEME is the literal "file://"
URL_SEP is the literal '/'
baseURL is the result of
System.getProperty("user.dir").replace('\\','/')
Windows:
user.dir=C:\Users\user\work
baseURL=file:///C:/Users/user/work/
Linux:
user.dir=/home/user/work
baseURL=file:////home/user/work/
Maybe it could use just:
baseURL = new java.io.File(System.getProperty("user.dir"))
.toURI().toString();
file:/C:/Users/user/work/
file:/home/user/work/
FWIW, the java.nio.file produces slightly different results:
baseURL = new java.io.File(System.getProperty("user.dir"))
.toPath().toUri().toString();
file:///C:/Users/user/work/
file:///home/user/work/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org