Click here to Skip to main content
12,699,489 members (34,813 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB9.0 VB XML XSLT VB.NET
I have a project that errors on:
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()

        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))

        xslt.Transform(sourceReader, Nothing, writer)
    Catch ex As Exception
        xFrmTlogs = ex.ToString
    End Try

    HTMLoutput = writer.ToString()
    xFrmTlogs = HTMLoutput
End Function

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
Posted 2-Dec-12 13:22pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try reading the exception message. "Could not find a part of the path 'H:\Program Files\common\tr_period.xsl'" seems to be pretty specific about what the problem is.
xardoz 2-Dec-12 21:39pm
I am not trying to open a path to a file!
That is why I stated I am passing it a string....

That is the question....
Dave Kreskowiak 2-Dec-12 22:21pm
Again, read the error message. There is apparently a file specified in the XSLT file that doesn't exist.
xardoz 2-Dec-12 23:42pm
I am passing the XSLT as a string, Why is it creating an error on a file path?
xardoz 3-Dec-12 19:09pm
Thank You, Totally missed the file path in the XLST.
xardoz 3-Dec-12 19:09pm
Why would there be a file link is the XSLT?
Dave Kreskowiak 3-Dec-12 20:41pm
What you posted included a XSL file so the XSLT could use it without having to refine the entire XSL file again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 2 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100