2011-06-16 56 views
0

如何在Asp.net/VB中啓用xsltSettingf EnableDocumentFunction以便在XSLT中使用document()?EnableDocumentFunction Asp.net XSLT XML

Public Shared Function xmlGetter(ByVal strXSLTFile As String, ByVal strXMLFile As String) As String 

    Dim reader As XmlReader = XmlReader.Create(strXMLFile) 
    Dim objXSLTransform As New XslCompiledTransform() 

    Dim xsltSettings As New XsltSettings() 
    xsltSettings.EnableDocumentFunction = True 


    objXSLTransform.Load(strXSLTFile) 

    Dim htmlOutput As New StringBuilder() 
    Dim htmlWriter As TextWriter = New StringWriter(htmlOutput) 
    objXSLTransform.Transform(reader, Nothing, htmlWriter) 

    Dim s As String 
    s = htmlOutput.ToString() 
    Return s 
    reader.Close() 
End Function 

回答

1

有跡象表明,採取XsltSettings Load方法(如http://msdn.microsoft.com/en-us/library/ms163426.aspx)的重載:objXSLTransform.Load(strXSLTFile, xsltSettings, Nothing)

+2

昏暗XSLT作爲新XslCompiledTransform() 暗淡設置作爲新XsltSettings() settings.EnableDocumentFunction =真 xslt.Load( 「style.xslt」,設定新XmlUrlResolver()) – user168507 2011-06-16 11:54:30