问题描述
我有一个错误的项目:
xslt.Load(New XmlTextReader(New StringReader(sXLST.ToString)))
我正在传递一个字符串,但似乎该函数正在尝试访问文件。
这是代码,然后是错误...
I am passing a string, but it appears that the function is trying a access a file.
Here is the code, follow by the error...
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 \ commonmon \ tr_period.xsl的一部分。在System.IO .__ Error.WinIOError(的Int32的errorCode,字符串maybeFullPath)在System.IO.FileStream.Init(字符串路径,模式的FileMode,FileAccess的访问,的Int32权利,布尔useRights,文件共享份额,缓冲区大小的Int32,FileOptions选项,SECURITY_ATTRIBUTES secAttrs System.IO.FileStream..ctor(String path,FileMode模式,FileAccess访问,FileShare共享,Int32 bufferSize)中的System.Xml.XmlDownloadManager.GetStream(Uri uri,ICredentials凭证)处于System,System msgPath,Boolean bFromProxy)。 Xml.XmlUrlResolver.GetEntity(URI绝对URI,字符串的作用,类型ofObjectToReturn)在System.Xml.Xsl.Xslt.XsltLoader.CreateReader(URI URI,的XmlResolver的XmlResolver)在System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(URI URI,布尔包括)在System.Xml.Xsl.Xslt.XsltLoader.LoadInclude()在System.Xml.Xsl.Xslt.XsltLoader.LoadRealStylesheet()在System.Xml.Xsl.Xslt.XsltLoader.LoadDocument()在的System.Xml。 Xsl.Xslt.XsltLoader.LoadStylesheet(XmlReader reader,Boolean include)---内部异常结束上堆栈跟踪---在System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(的XmlReader读取器,布尔包括)在System.Xml.Xsl.Xslt.XsltLoader.Load(编译器的编译器,对象的样式表,的XmlResolver的XmlResolver)在系统。 Xml.Xsl.Xslt.Compiler.Compile(对象样式表,XmlResolver xmlResolver,QilExpression& ()System.Xml.Xsl.XslCompiledTransform上的System.Xml.Xsl.XslCompiledTransform.CompileXsltToQil(对象样式表,XsltSettings设置,XmlResolver stylesheetResolver)中的System.Xml.Xsl.XslCompiledTransform.LoadInternal(对象样式表,XsltSettings设置,XmlResolver stylesheetResolver) .Load(的XmlReader样式表)在VfiSapphire.COMWrapper.xFrmTlogs(字符串sXLST,字符串sXML)在H:\Documents和Settings\xxx\My Documents\Visual Studio2008\ProgramName\ModuleName\PdkBo.vb:第709行
The output for the error is:
System.Xml.Xsl.XslLoadException: XSLT compile error. An error occurred at (3,2). --- System.IO.DirectoryNotFoundException: Could not find a part of the path ''H:\Program Files\common\tr_period.xsl''. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at 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.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) at System.Xml.Xsl.Xslt.XsltLoader.CreateReader(Uri uri, XmlResolver xmlResolver) at System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(Uri uri, Boolean include) at System.Xml.Xsl.Xslt.XsltLoader.LoadInclude() at System.Xml.Xsl.Xslt.XsltLoader.LoadRealStylesheet() at System.Xml.Xsl.Xslt.XsltLoader.LoadDocument() at System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(XmlReader reader, Boolean include) --- End of inner exception stack trace --- at System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(XmlReader reader, Boolean include) at System.Xml.Xsl.Xslt.XsltLoader.Load(Compiler compiler, Object stylesheet, XmlResolver xmlResolver) at System.Xml.Xsl.Xslt.Compiler.Compile(Object stylesheet, XmlResolver xmlResolver, QilExpression& qil) at System.Xml.Xsl.XslCompiledTransform.CompileXsltToQil(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet) at VfiSapphire.COMWrapper.xFrmTlogs(String sXLST, String sXML) in H:\Documents and Settings\xxx\My Documents\Visual Studio2008\ProgramName\ModuleName\PdkBo.vb:line 709
推荐答案
这篇关于VB Net 2008 XML& XLST问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!