Bug #2314
closedStylesheet Base Uri with spaces causes issues when compiling stylesheet [Saxon.HE 9.6N]
100%
Description
Apparently another change in behavior that looks a bit like a regression when switching from 9.5 to 9.6.
We frequently do in-memory transformations where both the input document and the XSLT are not actual files but strings/byte-buffers/XML fragments.
However, to run XsltCompiler.Compile
correctly with a XmlReader
(for example), it must have XsltCompiler.BaseUri
set to a valid Uri. The path pointed to by the Uri need not exist, and it does not make a difference what I set it to since all the XSLTs we run that way are standalone, without any includes.
Therefore, whenever we have to set that path to something, we simply use the assembly path - since its not used anyways.
With 9.5, this worked just fine when the application is installed below C:\Program Files (with the space in there).
However, 9.6 throws an XPathException:
HResult=-2146233088
Message=Invalid URI for stylesheet: file:///c:/path with space/nonexistant.xsl
Source=saxon9he
StackTrace:
at net.sf.saxon.style.StylesheetModule.loadStylesheetModule(Source styleSource, Boolean topLevelModule, Compilation compilation, NestedIntegerValue precedence)
at net.sf.saxon.style.Compilation.compilePackage(Source source)
at net.sf.saxon.style.Compilation.compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source)
at Saxon.Api.XsltCompiler.Compile(XmlReader reader)
at ConsoleApplication1.Program.Main(String[] args) in c:\Users\emanuel.wlaschitz\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Sample code:
static void Main(string[] args)
{
Uri stylesheetBaseUri = new Uri(@"c:\path with space\nonexistant.xsl");
var xsl = XDocument.Parse(@"<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match='/'><foo/></xsl:template>
</xsl:stylesheet>");
var compiler = new Processor(false).NewXsltCompiler();
compiler.BaseUri = stylesheetBaseUri;
//throws an exception when:
//- compiler.BaseUri is null
//- compiler.BaseUri contains a space (although the Uri instance correctly escape the space to %20)
compiler.Compile(xsl.CreateReader());
}
This is on 9.6.0.4 running on .NET 4.5, in case it matters.
Please register to edit this issue