为什么外部文档在Altova XMLSpy中解析而不是在SaxonHE10中解析?



我想将一个外部xml文档加载到一个变量中,该变量在Altova XMLSpy中工作,但在SaxonHE10中不工作。

在Altova XMLSpy中,以下XSLT 2.0行返回true

<xsl:copy-of select="fn:doc-available('https://www.xrepository.de/api/version_codeliste/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:staat_2019-02-01/genericode')"/>

在我本地的SaxonHE10安装中,它返回false

我可以使用任何命令行参数来改变这种行为吗?

新增18.10.2021 13:12:评论区列表太小了,所以我编辑了我的问题:这就是XSLT:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdf3="urn:xoev-de:fim:standard:xdatenfelder_3.0.0" 
xmlns:gc="http://docs.oasis-open.org/codelist/ns/genericode/1.0/" 
exclude-result-prefixes="html"
>
<xsl:template match="/">
<xsl:message>
<xsl:copy-of select="fn:doc-available('https://www.xrepository.de/api/version_codeliste/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:staat_2019-02-01/genericode')"/>
</xsl:message> 
<xsl:message>
<xsl:copy-of select="fn:document('https://www.xrepository.de/api/version_codeliste/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:staat_2019-02-01/genericode')"/>                                  
</xsl:message> 
</xsl:template>
</xsl:stylesheet>

这是命令调用:

"C:Program FilesSaxonicaSaxonHE10.2NbinTransform.exe" -s:test.xml -xsl:test.xsl 

结果如下:

false
Error FODC0002 while evaluating xsl:message at line 20 of file:/C:/Users/Volker/Dropbox/FIM/Tools/QS%20Datenfelder/test.xsl: Document has been marked not available: https://www.xrepository.de/api/version_codeliste/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:staat_2019-02-01/genericode
<?xml version="1.0" encoding="UTF-8"?>

有趣的是,在我运行的基于Saxon . net的XSLT fiddle应用程序中,对给定URL的doc和doc-available调用可以工作。

据我所知,这是我在网络上唯一的IKVM设置。配置(也可以在app.config中工作,用于非web使用。net和Saxon)是TLS设置,例如

<configuration>

<appSettings>
<add key="ikvm:https.protocols" value="TLSv1,TLSv1.1,TLSv1.2" />
</appSettings>
</configuration>

因此,值得一试的是,任何使用Saxon的. net用户,如果URI失败,请将上述设置添加到app.config或web.config中。

我现在尝试使用Saxon HE 10.6 . net编写一些简单的c#代码,例如

Processor processor = new Processor();
string xpathExpression = "doc-available('https://www.xrepository.de/api/version_codeliste/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:staat_2019-02-01/genericode')";
Console.WriteLine(processor.NewXPathCompiler().EvaluateSingle(xpathExpression, null).GetStringValue());
Console.ReadLine();
没有>对IKVM设置或app.config的任何更改都会输出true。事实证明,所使用的。net框架版本是决定性的或部分原因,第一次测试是在4.8上完成的。使用4.5为false,使用4.6为true。

即使不使用Saxon或IKVM,一个。net framework 4.5应用程序也可以完成

string url = "https://www.xrepository.de/api/version_codeliste/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:staat_2019-02-01/genericode";
var request = WebRequest.Create(url);
{
using (var response = (HttpWebResponse)request.GetResponse())
{
Console.WriteLine("Status: {0}", response.StatusCode);
response.Close();
}
}
Console.ReadLine();

无法建立连接,因为它给出了一些关于无法建立受保护的SSL/TLS通道的错误。使用。net framework 4.8就不会出现这样的问题。仍然不知道如何从Saxon获得编译和安装。exe文件,如Transform.exe或Query.exe,以切换/寻找最新/最高安装的。net框架,而不是(我假设)它们被编译和测试运行的最低。https://learn.microsoft.com/en-us/dotnet/framework/network-programming/tls可能会给我们一些线索。

最新更新