Tag: saxon

从Saxon 9.4he中的嵌入资源加载xml和xslt

我使用Saxon 9.4家庭版( Saxon-HE 9.4 .NET )来获得对XSLT 2.0和XPath 2.0以及.NET中的XQuery 1.0的支持。 当我加载没有URI的文件时,我的代码崩溃了。 是否可以在没有与加载的文档相关的URI的情况下加载xml / xsl文档? 如果没有,有没有办法为嵌入在dll文件中的元素定义URI? 任何其他解决方案也将受到赞赏,我唯一的术语是必须从dll文件中加载文件。 只要我从文件加载xml / xsl,我的代码就可以正常工作: const string sourcePath = @”C:\test\TestInvoiceWithError.xml”; const string xsltpath = @”C:\test\UBL-T10-BiiRules.xsl”; 当我尝试从嵌入式资源加载时,代码抛出一个exception,说明“没有提供基本URI” : Stream sourceStream = GetEmbeddedResource(“TestProject1.testfiles.TestInvoice.xml”); Stream xsltStream = GetEmbeddedResource(“TestProject1.testfiles.UBL-T10-BiiRules.xsl”); 我还为具有相对路径的资源创建了Uri,这会引发exception“相对URI不支持此操作”。 : Uri sourceUri = new Uri(“/TestProject1;component/testfiles/TestInvoice.xml”, UriKind.Relative); Uri xsltUri = new Uri(“/TestProject1;component/testfiles/UBL-T10-BiiRules.xsl.xml”, UriKind.Relative); 这是我的代码: using System; […]