Project

Profile

Help

Problems resolving local Uri's as the BaseUri when loctions include numbers

Added by Terry Reese almost 10 years ago

I'm hoping I'm just missing something -- but when I attempt to set a baseuri to a local file that has a folder with a space and a number, I get an error (using .NET). For example:

System.Uri localURI = new Uri(@"C:\Users\reeset\Documents\Visual Studio 2012\Projects\xquery_test\xquery_test\bin\Debug\modules"); xq.BaseUri = localURI.AbsoluteUri;

System.IO.StreamReader reader = new System.IO.StreamReader(xqueryfile, false); Saxon.Api.XQueryExecutable exp = xq.Compile(reader.ReadToEnd()); reader.Close();

On compile, I get the following error: Error on line 59 column 1 of file:///c:/Users/reeset/Documents/Visual%20Studio%202012/Projects/xquery_test/xquery_test/Debug/modules/

The problem seems to be at the %202012 -- the numerical value in the folder name with the escaped space seems to be causing a problem. If I remove the numerical value, but keep everything else the same, the exact same code works. i.e.

System.Uri localURI = new Uri(@"C:\Users\reeset\Documents\Visual Studio\Projects\xquery_test\xquery_test\bin\Debug\modules"); xq.BaseUri = localURI.AbsoluteUri;

System.IO.StreamReader reader = new System.IO.StreamReader(xqueryfile, false); Saxon.Api.XQueryExecutable exp = xq.Compile(reader.ReadToEnd()); reader.Close();

The problem I'm running into is that if I'm picking up files off the local file system, I can't guarantee that the baseuri won't be in this format -- so I'm curious if there is a solution around this problem.

Thanks,

--tr


Replies (1)

RE: Problems resolving local Uri's as the BaseUri when loctions include numbers - Added by Terry Reese almost 10 years ago

Follow up --

If I turn this into a relative path, i.e., substitute out the folder with the problem with a ".", the paths resolve. So, this works:

System.Uri localURI = new Uri(@"C:\Users\reeset\Documents.\xquery_test\xquery_test\bin\Debug\modules"); xq.BaseUri = localURI.AbsoluteUri;

System.IO.StreamReader reader = new System.IO.StreamReader(xqueryfile, false); Saxon.Api.XQueryExecutable exp = xq.Compile(reader.ReadToEnd()); reader.Close();

I could certainly create a function that cleans local paths to remove folders that will be problematic -- I'm just not sure if there will be unintended consequences that I'm not going to be able to see in limited tested. Plus, it seems like there should be a better way of doing this.

Thanks,

--tr

    (1-1/1)

    Please register to reply