xslt-1.0 - 撒克逊人抱怨未知功能虽然功能可用
问题描述
我正在通过 xslt 转换某些东西,如果 xalan 函数可用,则尝试使用document-location
它,否则避免使用它(便携式)。示例代码:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="function-available('document-location')">
<xsl:message>YES document-location
</xsl:message>
<xsl:message><xsl:value-of select="document-location()"/></xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:message>NO document-location
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:transform>
撒克逊报告
SAXON 6.5.5 from Michael Kay
Java version 1.7.0_151
Error at xsl:value-of on line 8 of file:minisax.xsl:
Error in expression document-location(): Unknown system function: document-location
Transformation failed: Failed to compile stylesheet. 1 error detected.
虽然之前的功能可用测试。尝试使用它。它似乎试图在“控制”达到这一点之前使用它。
它适用于 xalanj(这很容易),但也适用于 xsltproc。
我怎样才能使这项工作?
编辑/背景
那是我的 Renderx XEP 评估附带的 saxon 版本,因此很难编写可移植的样式表以开箱即用。我知道由于古老的版本,这不是当前的撒克逊问题。
解决方案
Saxon 6.5.5 是一个非常古老的版本,我建议您转向更现代的版本。样式表在 Saxon 9.9 中似乎可以正常工作。
我不打算研究 Saxon 6.5.5 源代码,但一种可能性是它假设规范不允许您将函数添加到默认(系统定义)函数命名空间,因此它可以静态假设它知道该命名空间中存在哪些函数。Xalan 通过向系统命名空间添加一个非标准函数显然打破了这一规则,而 Saxon 并没有考虑到这一点。
推荐阅读
- c - 在 C 中为缓冲区(结构类型)分配内存
- x86-64 - 如何使用 SSE 模拟*非常简单*的可变位移?
- r - 使用命令 over() 时收到错误消息
- javascript - 试图通过它的特定元素从数组中删除对象
- python - 找到但无法从当前工作目录加载的 dll
- ios - 如何在使用 Firebase Auth 创建用户期间验证字段服务器端?
- javascript - 反应 CSSTransition 没有动画
- python - 计算球体的体积和表面积的输出
- javascript - 使用 Vue.JS/Axios 和来自第三方 API(基于 Django!)的数据填充 DOM
- java - 拦截对 MongoDB Spring Boot 的所有写调用