我正在通过 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 版本,因此很难编写可移植的样式表以开箱即用。我知道由于古老的版本,这不是当前的撒克逊问题。