 |
 |
 |
I am using a xsl template, but I need to create that on the fly into a
stream. As well ast the xml file generated by the database. Can anyone
help me. My working code is below....
String conn = "Password=sa;User ID=sa;Initial Catalog=pubs;Data
Source=xxxxxx";
String sql = "Select * From Royalties ";
String xslPath = "RoyaltyReportStyle.xsl";
String ServerPath = HttpContext.Current.Server.MapPath("\\" +
ConfigurationSettings.AppSettings["xmlPath"] + "\\");
//Filter for a selected author
//DataRowView item = (DataRowView)nameList.Items[index];
String filter = "Karsen";
//Get Royalty data
SqlDataAdapter adapter = new SqlDataAdapter();
SqlConnection connection = new SqlConnection(conn);
SqlCommand command = new SqlCommand(sql + "where au_lname='" +
filter + "'", connection);
adapter.SelectCommand = command;
DataSet data = new DataSet("root");
adapter.Fill(data, "royalties");
//Transform the data
// string val = HttpContext.Current.Server.MapPath("\\" +
ConfigurationSettings.AppSettings["xmlPath"] + "\\" + filter + ".xml");
data.WriteXml(ServerPath + filter + ".xml");
// data.WriteXml("C:\\Inetpub\\wwwroot\\excelTransform\\Karsen.xml");
// Create a resolver with default credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Create the XslTransform object.
XslTransform xslt = new XslTransform();
// Load the stylesheet.
xslt.Load("http://localhost/excelTransform/RoyaltyReportStyle.xsl",
resolver);
// Transform the file.
xslt.Transform(ServerPath + filter + ".xml", ServerPath + filter +
"Report.xml", resolver);
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |