当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP处理XSLT转换XML的实现

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

ASP处理XSLT转换XML的实现


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 109 ::
收藏到网摘: n/a

使用ASP处理XSLT转换XML比较简单,思路如下:创建一个XSLTemplate的对象,再创建一个XMLDOM对象,然后在家Xml文件和XSLT文件,最后使用方法transform即可,包含到类里面,具体代码如下:
以下是引用片段:

Class Cls_Xml_Transform
    Private lInput,XSLTemplate
    Private p_Output
    Public Property Get Output()
        Output = p_Output
    End Property
    Private Property Let Output(ByVal strInfo)
        p_Output = strInfo
    End Property
    Public Property Let Input(ByVal vNewValue)
        If IsObject(vNewValue) Then Set lInput=vNewValue
    End Property
    Public Property Let XSLTemplatefile(ByVal vNewValue)
        Dim StyleSheet
        Dim vNewValue_
        vNewValue_ = vNewValue
        If Not InStr(vNewValue,":\") > 0 Then
            vNewValue  = Server.MapPath(vNewValue)
        End If
        Set XSLTemplate=Server.CreateObject("Msxml2.XSLTemplate")
        Set StyleSheet=Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
        StyleSheet.load vNewValue
        XSLTemplate.StyleSheet=StyleSheet
    End Property
    Public Sub Transform()
        Dim proc
        Set proc = XSLTemplate.createProcessor()
        proc.input=linput
        proc.transform()
        Output=proc.output
        Set proc=Nothing
    End Sub
End Class

使用范例:

以下为引用的内容:
Set XMLDOM = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
XMLDOM.async = false
XMLDOM.load(Server.MapPath("bi2.xml"))
Set o=new Cls_IO_Transform
o.XSLTemplatefile="bi2.xsl"
o.Input=XMLDOM
o.Transform()
response.write o.Output()

这里处理的直接是XmlDom对象了,如果需要,灵活可以修改。