以下は、エラーの原因となっているコードです。XSL と ASP.NET の初心者として、エラーが発生する理由がよくわかりません...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="view.aspx.cs" Inherits="ININ.Marquee.Web.view" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<html>
<head>
</head>
<body>
<form id="form1" runat="server" >
<div>
<script runat="server">
public string GetXMLAsString(XmlDocument myxml)
{
StringWriter sw = new StringWriter();
XmlTextWriter tx = new XmlTextWriter(sw);
myxml.WriteTo(tx);
string str = sw.ToString();//
return str;
}
public static string GetHtml(string xsltPath, string xml)
{
MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xml));
XPathDocument document = new XPathDocument(stream);
StringWriter writer = new StringWriter();
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(xsltPath);
transform.Transform(document, null, writer);
return writer.ToString();
}
public string details = string.Empty;
private void Page_Load(object sender, EventArgs e)
{
/******** - This the START of all the Database Stuff - ********/
// Create a String to hold the database connection string.
// NOTE: Put in a real database connection string here or runtime won't work
string sdwConnectionString = @"Data Source = server; user id=username; password=password; Initial Catalog = database;";
// Create a connection
SqlConnection sdwDBConnection = new SqlConnection(sdwConnectionString);
// Open the connection
sdwDBConnection.Open();
// Create a String to hold the query.
string query = "SELECT * from IWrkgrpQueueStats WHERE ((substring(convert(char,dIntervalStart,120),1,10) = substring(convert(char,getdate(),120),1,10)) AND (cName IN ('Password','Arbour/CMBS/Other','Incident Escalation', 'OPOM/SOS/MyAccount','PC/Outlook','Overflow')) AND (cReportGroup='*' AND cHKey3='*' AND cHKey4='*'))";
// Create a SqlCommand object and pass the constructor the connection string and the query string.
SqlCommand queryCommand = new SqlCommand(query, sdwDBConnection);
// Use the above SqlCommand object to create a SqlDataReader object.
SqlDataReader queryCommandReader = queryCommand.ExecuteReader();
//Create a DataTable object to hold all the data returned by the query.
DataTable duplicatedataTable = new DataTable();
// Use the DataTable.Load(SqlDataReader) function to put the results of the query into a DataTable.
duplicatedataTable.Load(queryCommandReader);
// Open the connection
sdwDBConnection.Close();
DataSet ds = new DataSet("interactions");
ds.Tables.Add(duplicatedataTable);
string XML = ds.GetXML();
details=GetHtml(Server.MapPath("~/Test.xsl"), XML);
}
</script>
<table width="100%">
<tr>
<td align="left">
<table width="100%" border="0">
<tr bgcolor="Silver">
<th align="center">
<%= details %>
</th>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
このコードと .xsl コードの両方を確認しましたが、問題はないようです。エラーの意味と、エラーの原因となっている問題がどこで発生するかを誰か説明してもらえますか? ご協力ありがとうございます。