使用VBScript向XSLT添加参数时出现类型不匹配问题

时间:2011-10-02 10:00:18

标签: vbscript xslt

我在VBScript中有以下代码:

<%

Option Explicit  

#importXSLT "tcm:228-190529-2048" As expandXSLT
#importXSLT "tcm:228-642694-2048" As renderXSLT

Dim xml, currentDateTime

Set xml = getNewDomDocument()
xml.loadXML TDSE.GetListPublications(3)

expandXSLT.input = xml
Call expandXSLT.addParameter("publication", Component.Publication.Id)
expandXSLT.transform

xml.loadXML(expandXSLT.output)
'WriteOut xml.xml

currentDateTime = now
renderXSLT.input = xml
Call renderXSLT.addParameter("currentPublishedDate", currentDateTime)
renderXSLT.transform

WriteOut renderXSLT.output

Set xml = Nothing

%>

您可以看到我添加XSLT参数有两种语法,第一种是正常工作,即

expandXSLT.input = xml
Call expandXSLT.addParameter("publication", Component.Publication.Id)
expandXSLT.transform

然而新的要求是,我们需要将当前日期时间从这里发送到XSLT,所以我添加了相同的逻辑来发送当前日期&amp;我的XSLT的时间,下面是我添加的代码

 currentDateTime = now
    renderXSLT.input = xml
    Call renderXSLT.addParameter("currentPublishedDate", currentDateTime)
    renderXSLT.transform

但是当我试图运行上面的代码时,它给出了以下错误:

类型不匹配。  (来源:调用renderXSLT.addParameter(“publishedDate”,currentDateTime))。

请建议!!

1 个答案:

答案 0 :(得分:0)

尝试先将您拥有的currentDateTime值转换为字符串,然后将该字符串传递给XSLT,例如CStr(currentDateTime)