我想将一个外部XML文档加载到一个变量中,这在Altova XMLSpy中有效,但在SaxonHE10中无效。
在Altova XMLSpy中,下面的XSLT2.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 Files\Saxonica\SaxonHE10.2N\bin\Transform.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"?>发布于 2021-10-18 12:55:24
有趣的是,对给定URL的doc和doc-available调用在我运行的基于.NET的Saxon XSLT fiddle应用程序中有效。
据我所知,我在web.config中拥有的唯一的IKVM设置(对于.NET和Saxon的非web使用,也可以在app.config中工作)是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,则输出为真。事实证明,所使用的.NET框架版本是决定性的或部分原因,第一个测试是在4.8版本中完成的。使用4.5表示false,使用4.6表示true。
即使不使用Saxon或IKVM,.NET Framework4.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 Framework4.8就不会出现这样的问题。我仍然不知道如何从Saxon开始编译和安装.exe文件,如Transform.exe或Query.exe,以切换/查找最新/最高安装的.NET框架,而不是(我假设)它们被编译和测试的最低版本。https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls可能会给出一些线索。
https://stackoverflow.com/questions/69603608
复制相似问题