[英]XSLT xmlXPathCompOpEval: function new not found
我正在尝试执行我的xsl文件,并收到一条错误消息,提示未找到新功能。
执行我的xsl的命令: xsltproc GetRequestTransformation.xsl xsltTest.xml
每当我尝试在Linux机器上执行上述命令时,都会出现以下错误:
compilation error: file GetRequestTransformation.xsl line 5 element stylesheet
xsl:version: only 1.0 features are supported
xmlXPathCompOpEval: function new not found
XPath error : Unregistered function
xmlXPathCompOpEval: parameter error
runtime error: file GetRequestTransformation.xsl line 15 element variable
Failed to evaluate the expression of variable 'currentDate'.
这是我的XSLT文件GetRequestTransformation.xsl :
<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version='2.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:java="http://xml.apache.org/xslt/java" xmlns:SimpleDateFormat="java.text.SimpleDateFormat"
xmlns:Date="java.util.Date" exclude-result-prefixes="java SimpleDateFormat Date">
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:max="http://www.ibm.com/maximo">
<soapenv:Header/>
<soapenv:Body>
<max:CreateWS_INCID_AFEC_TB>
<max:WS_INCID_AFEC_TBSet>
<max:DURACION>
<xsl:variable name="affectedFinish" select='/tTroubleticket/alarms/tTroubleticketalarm/clearDate' />
<xsl:variable name="affectedStart" select='/tTroubleticket/alarms/tTroubleticketalarm/activationDate' />
<xsl:variable name="currentDate" select="SimpleDateFormat:format(SimpleDateFormat:new('yyyy-MM-dd HH:mm:ss'), Date:new() />
<xsl:choose>
<xsl:when test="$affectedFinish != null">
<xsl:value-of select="$affectedFinish - $affectedStart" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentDate - $affectedStart" />
</xsl:otherwise>
</xsl:choose>
</max:DURACION>
</max:WS_INCID_AFEC_TBSet>
</max:CreateWS_INCID_AFEC_TB>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
映射XML文件xsltTest.xml :
<tTroubleticket>
<alarms>
<tTroubleticketalarm>
<activationDate>2015-04-01 12:42:22.0</activationDate>
<clearDate>null</clearDate>
</tTroubleticketalarm>
</alarms>
</tTroubleticket>
您能否尝试找出我的xsl文件的问题。 我在执行该命令之前会丢失任何东西吗? 我该如何解决?
您尝试使用的Java扩展功能机制特定于Xalan Java XSLT处理器,在xsltproc
(不是用Java编写)中不起作用。 如果要从命令行执行此样式表,则需要下载Xalan并运行其命令行工具
java -cp xalan.jar:serializer.jar org.apache.xalan.xslt.Process -XSL GetRequestTransformation.xsl -IN xsltTest.xml
第14行,在Date:new()
:括住括号和引号:
<xsl:variable name="currentDate" select="SimpleDateFormat:format(SimpleDateFormat:new('yyyy-MM-dd HH:mm:ss'), Date:new())" />
伊恩·罗伯茨的眼神比我大。 假定命令行是由用Java编写的处理器(即Xalan或Saxon)运行的,我仅浏览了命令行部分并仅关注您的XSLT代码。
FWIW,您不需要使用Java来获取当前日期:libxslt和Xalan都支持EXSLT date:date()
和date:time()
扩展功能。 libxslt还支持date:date-time()
和date:difference()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.