vb.net xslt.Load(New XmlTextReader(New StringReader(xslt))) "xslt 编译错误"
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13672823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xslt.Load(New XmlTextReader(New StringReader(xslt))) "xslt compile error"
提问by Xardoz
I have read the other posts and they are not resolving my problem.
The environment is VB 2008 (2.0 Framework)
The below code cause an XSLT Compile erroron the xslt.Loadline
Below that is the output from the error. I am passing the XSLT as a string, so not sure why I am getting the error I am.
我已经阅读了其他帖子,但它们并没有解决我的问题。环境2008 VB(2.0框架)以下原因代码的一个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 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
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. Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) 在 System.Xml.Xsl.Xslt.XsltLoader。
回答by Steven Doggart
The XSLT script that is stored in sXSLTlikely contains a <xsl:include>or an <xsl:import>element which tries to include/import another XSLT script file at H:\Program Files\common\tr_period.xsl. Since that file doesn't exist, or is otherwise inaccessible, the transform fails.
存储在的 XSLT 脚本sXSLT可能包含一个<xsl:include>或一个<xsl:import>元素,该元素试图在H:\Program Files\common\tr_period.xsl. 由于该文件不存在或无法访问,因此转换失败。

