以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  使用MSXML4进行XSL转换的问题?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=6451)


--  作者:stonewx
--  发布时间:4/5/2004 11:06:00 AM

--  使用MSXML4进行XSL转换的问题?
set XSLSheet=new MSXML2.FreeThreadedDOMDocument40
'读取XSLT文件
If XSLSheet Is Nothing Then
    sXSLT = App.Path & "\data\test.xsly"
    ''读取XSLT转换文件,要求使用FreeThreadedDOMDocument40对象
    Set XSLSheet = New MSXML2.FreeThreadedDOMDocument40
    XSLSheet.async = False
    XSLSheet.setProperty "SelectionLanguage", "XPath"
    If XSLSheet.Load(sXSLT) = False Then
        Beep
        MsgBox "读取XSLT转换文件出错!"
        exit sub
    End If
End If
'使用XSLTemplate40创建XSLT处理对象
If XSLTemplate Is Nothing Then
    Set XSLTemplate = New MSXML2.XSLTemplate40
    Set XSLTemplate.stylesheet = XSLSheet
    If Err.Number <> 0 Then MsgBox Err.Description, vbCritical, "错误"
将XSLProcessor对象缓存,可以反复使用,比起每次调用DOMDocument40的transformNode方法要快
    Set XSLProcessor = XSLTemplate.createProcessor
    If Err.Number <> 0 Then
        MsgBox Err.Description
        Set XSLTemplate = Nothing
        Exit Sub
    End If
'End If
'
载入源XML文档
If mXML.loadXML(sXML) = False Then                      '载入不成功
    Exit Sub
End If
***********************************
* 为什么出错?  
* 此处出错,跟踪调试发现XSLProcessor.input一直是空值?
***********************************

Set XSLProcessor.input = mXML     

***********************************
If Err.Number <> 0 Then MsgBox Err.Description, vbCritical, "错误"

开始执行转换
XSLProcessor.Transform


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms