【发布时间】:2016-03-01 22:12:18
【问题描述】:
我需要帮助解决我的一个问题。我是 XSLT 的新手。现在我正在尝试编写一个将生成文本输出的 XSLT(例如:“01:30”)。
在我的 XSLT 2.0 中,我调用了 XPath 函数 hours-from-duration($duration),而这个函数抛出了错误
XPath 无效
我还可以在以下日志中看到上述错误。请帮我解决我的问题。谢谢...
16:01:39,403 错误 [main] JAXPSAXProcessorInvoker - 检查表达式“funcall(hours-from-duration, [variable-ref(duration/node-set)])”的类型时出错。
16:01:39,404 错误 [main] JAXPSAXProcessorInvoker - 无法编译样式表
javax.xml.transform.TransformerConfigurationException:无法在 com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:858) 在 com.sun.org.apache 编译样式表.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:648)
我的 XSLT:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:str="http://exslt.org/strings"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="text" />
<xsl:variable name="request" select="/*[local-name()='Payout']/*[local-name()='Request']" />
<xsl:variable name="duration" select="$request/Time" />
<xsl:template match="/">
<xsl:value-of select="(hours-from-duration($duration))"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="(minutes-from-duration($duration))"/>
</xsl:template>
</xsl:stylesheet>
XML 输入:
<Payout>
<Request Commit="true" Transaction="false">
<Month>JAN</Month>
<Time>P01H30M33S</Time>
</Request>
</Payout>
【问题讨论】:
-
$duration设置在哪里?