我已经阅读了其他帖子,但它们并没有解决我的问题。环境是 VB 2008 (2.0 Framework) 下面的代码导致XSLT Compile error
在线xslt.Load
下面是错误的输出。我将 XSLT 作为字符串传递,所以不知道为什么会出现错误。
Public Function xFrmTlogs(ByVal sXLST As String, ByVal sXML As String) As String
Dim xslt As New XslCompiledTransform()
Dim HTMLoutput As String
Dim writer As New StringWriter()
Try
xslt.Load(New XmlTextReader(New StringReader(sXLST.ToString)))
Catch ex As Exception
xFrmTlogs = ex.ToString
End Try
Dim sourceReader As System.Xml.XmlReader = System.Xml.XmlReader.Create(New System.IO.StringReader(sXML))
Try
xslt.Transform(sourceReader, Nothing, writer)
Catch ex As Exception
xFrmTlogs = ex.ToString
End Try
HTMLoutput = writer.ToString()
writer.Close()
xFrmTlogs = HTMLoutput
End Function
System.Xml.Xsl.XslLoadException:XSLT 编译错误。(3,2) 处发生错误。--- System.IO.DirectoryNotFoundException:找不到路径“H:\Program Files\common\tr_period.xsl”的一部分。在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs , String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) at System。 System.Xml.Xsl.Xslt.XsltLoader 中的 Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)。