Home > How-To Library > XSL Handling

Create XSL

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
Public Function createXSL(XslFile As String) 'This code is used to create XSL. Dim fso As New Scripting.FileSystemObject Dim objXSL As Object Dim strTemp As String, strXSL As String strXSL = XslFile fso.CreateTextFile strXSL, False Set objXSL = fso.OpenTextFile(strXSL, ForAppending) strTemp = "<?xml version=""1.0""?>" _ & vbCrLf & "<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">" _ & vbCrLf & "<xsl:template match=""/"">" _ & vbCrLf & "<html>" _ & vbCrLf & "<Body>" _ & vbCrLf & "<Table Border=""1"" bordercolor= ""#808080"" cellspacing=""0"" cellpadding=""0"" width=""100%"">" _ & vbCrLf & "<tr style=""background:#999999;font-size:8.0pt; font-family:Tahoma;color:white"" align=""center"">" _ & vbCrLf & "<td width=""13%""><b>Date &amp; Time</b></td>" _ & vbCrLf & "<td width=""10%""><b>User Name</b></td>" _ & vbCrLf & "<td width=""11%""><b>Machine Name</b></td>" _ & vbCrLf & "<td width=""12%""><b>File Name</b></td>" _ & vbCrLf & "<td width=""13%""><b>Procedure Name</b></td>" _ & vbCrLf & "<td width=""6%""><b>Error No</b></td>" _ & vbCrLf & "<td width=""35%""><b>Error Description</b></td></tr>" _ & vbCrLf & "<xsl:for-each select=""ErrorLog/Error"">" strTemp = strTemp & "<xsl:if test=""ErrorDateTime !="""""">" _ & vbCrLf & "<tr style=""font-size:8.0pt;font-family:Tahoma; color:black"" align=""center"">" _ & vbCrLf & "<td width=""13%""><xsl:value-of select=""ErrorDateTime""/></td>" _ & vbCrLf & "<td width=""10%""><xsl:value-of select=""UserName""/></td>" _ & vbCrLf & "<td width=""11%""><xsl:value-of select=""MachineName""/></td>" _ & vbCrLf & "<td width=""12%""><xsl:value-of select=""DocName""/></td>" _ & vbCrLf & "<td width=""13%""><xsl:value-of select=""ProcName""/></td>" _ & vbCrLf & "<td width=""6%""><xsl:value-of select=""ErrNo""/></td>" _ & vbCrLf & "<td width=""35%""><xsl:value-of select=""ErrDesc""/></td></tr>" _ & vbCrLf & "</xsl:if>" _ & vbCrLf & "</xsl:for-each>" _ & vbCrLf & "</Table>" _ & vbCrLf & "</Body>" _ & vbCrLf & "</html>" _ & vbCrLf & "</xsl:template>" _ & vbCrLf & "</xsl:stylesheet>" objXSL.WriteLine strTemp objXSL.Close ExitHere: Err.Clear Set objXSL = Nothing Set fso = Nothing End Function

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.