Hi, The code below seems to work fine except that when the page is done running it won't let me access the file until after I reboot the computer. It gives the "another program is using this file" error. Any ideas? Also if there is a better way to do what
I am trying to do here any suggesstions would be very helpful. This is my first time using xsl stylesheets
DataSet dsTemplate =
new DataSet();
int UID = int.Parse( Session[ "UID" ].ToString() );
int SID = int.Parse( Session[ "SID" ].ToString() );
sqlStrings.UID = UID;
sqlStrings.SID = SID;
sqlStrings.refreshSQLStrings();
SqlConnection sqlConn =
new SqlConnection( sqlStrings.ConnectionString );
SqlDataAdapter daInstructor =
new SqlDataAdapter( sqlStrings.Instructor, sqlConn );
SqlDataAdapter daLectureTopics =
new SqlDataAdapter( sqlStrings.LectureTopics, sqlConn );
SqlDataAdapter daOffDays =
new SqlDataAdapter( sqlStrings.OffDays, sqlConn );
SqlDataAdapter daOutcomes =
new SqlDataAdapter( sqlStrings.Outcomes, sqlConn );
SqlDataAdapter daPFCustom =
new SqlDataAdapter( sqlStrings.PFCustom, sqlConn );
SqlDataAdapter daPFStandard =
new SqlDataAdapter( sqlStrings.PFStandard, sqlConn );
SqlDataAdapter daTA =
new SqlDataAdapter( sqlStrings.TA, sqlConn );
SqlDataAdapter daStandardScale =
new SqlDataAdapter( sqlStrings.StandardScale, sqlConn );
SqlDataAdapter daReadings =
new SqlDataAdapter( sqlStrings.Readings, sqlConn );
SqlDataAdapter daPolicies =
new SqlDataAdapter( sqlStrings.Policies, sqlConn );
SqlDataAdapter daImportantDates =
new SqlDataAdapter( sqlStrings.ImportantDates, sqlConn );
SqlDataAdapter daHolidays =
new SqlDataAdapter( sqlStrings.Holidays, sqlConn );
SqlDataAdapter daFeedBack =
new SqlDataAdapter( sqlStrings.FeedBack, sqlConn );
SqlDataAdapter daExtraMeetings =
new SqlDataAdapter( sqlStrings.ExtraMeetings, sqlConn );
SqlDataAdapter daCustomScale =
new SqlDataAdapter( sqlStrings.CustomScale, sqlConn );
SqlDataAdapter daSyllabi =
new SqlDataAdapter( sqlStrings.Syllabi, sqlConn );
PhaedoHD
Member
436 Points
156 Posts
XSL, rtf and html
Nov 28, 2005 08:50 PM|LINK
DataSet dsTemplate =
new DataSet(); int UID = int.Parse( Session[ "UID" ].ToString() ); int SID = int.Parse( Session[ "SID" ].ToString() );sqlStrings.UID = UID;
sqlStrings.SID = SID;
sqlStrings.refreshSQLStrings();
SqlConnection sqlConn =
new SqlConnection( sqlStrings.ConnectionString );SqlDataAdapter daInstructor =
new SqlDataAdapter( sqlStrings.Instructor, sqlConn );SqlDataAdapter daLectureTopics =
new SqlDataAdapter( sqlStrings.LectureTopics, sqlConn );SqlDataAdapter daOffDays =
new SqlDataAdapter( sqlStrings.OffDays, sqlConn );SqlDataAdapter daOutcomes =
new SqlDataAdapter( sqlStrings.Outcomes, sqlConn );SqlDataAdapter daPFCustom =
new SqlDataAdapter( sqlStrings.PFCustom, sqlConn );SqlDataAdapter daPFStandard =
new SqlDataAdapter( sqlStrings.PFStandard, sqlConn );SqlDataAdapter daTA =
new SqlDataAdapter( sqlStrings.TA, sqlConn );SqlDataAdapter daStandardScale =
new SqlDataAdapter( sqlStrings.StandardScale, sqlConn );SqlDataAdapter daReadings =
new SqlDataAdapter( sqlStrings.Readings, sqlConn );SqlDataAdapter daPolicies =
new SqlDataAdapter( sqlStrings.Policies, sqlConn );SqlDataAdapter daImportantDates =
new SqlDataAdapter( sqlStrings.ImportantDates, sqlConn );SqlDataAdapter daHolidays =
new SqlDataAdapter( sqlStrings.Holidays, sqlConn );SqlDataAdapter daFeedBack =
new SqlDataAdapter( sqlStrings.FeedBack, sqlConn );SqlDataAdapter daExtraMeetings =
new SqlDataAdapter( sqlStrings.ExtraMeetings, sqlConn );SqlDataAdapter daCustomScale =
new SqlDataAdapter( sqlStrings.CustomScale, sqlConn );SqlDataAdapter daSyllabi =
new SqlDataAdapter( sqlStrings.Syllabi, sqlConn );daInstructor.Fill( dsTemplate, "tblInstructor" );
daLectureTopics.Fill( dsTemplate, "tblLectureTopics" );
daOffDays.Fill( dsTemplate, "tblOffDays" );
daOutcomes.Fill( dsTemplate, "tblOutcomes" );
daPFCustom.Fill( dsTemplate, "tblPFCustom" );
daPFStandard.Fill( dsTemplate, "tblPFStandard" );
daTA.Fill( dsTemplate, "tblTA" );
daStandardScale.Fill( dsTemplate, "tblStandardScale" );
daReadings.Fill( dsTemplate, "tblReadings" );
daPolicies.Fill( dsTemplate, "tblPolicies" );
daImportantDates.Fill( dsTemplate, "tblImportantDates" );
daHolidays.Fill( dsTemplate, "tblHolidays" );
daFeedBack.Fill( dsTemplate, "tblFeedBack" );
daExtraMeetings.Fill( dsTemplate, "tblExtraMeetings" );
daCustomScale.Fill( dsTemplate, "tblCustomScale" );
daSyllabi.Fill( dsTemplate, "tblSyllabus" );
dsTemplate.WriteXml( "c:/Inetpub/wwwroot/Calypso/DataFiles/" + UID + "_" + SID + ".xml", System.Data.XmlWriteMode.IgnoreSchema );
string xmlPath = Server.MapPath("./DataFiles/" + UID + "_" + SID + ".xml"); string xslPath; if( type )xslPath = Server.MapPath("./Templates/web/" + ddlWeb.SelectedItem.Text.Trim() + ".xsl");
elsexslPath = Server.MapPath("./Templates/rtf/" + ddlRtf.SelectedItem.Text.Trim() + ".xsl");
//instantiate the XPathDocument ClassXPathDocument doc =
new XPathDocument( xmlPath ); //Instantiate the XPathDocument ClassXslTransform transform =
new XslTransform();transform.Load( xslPath );
string outPath; if( type )outPath = "c:/Inetpub/wwwroot/Calypso/test.html";
elseoutPath = "c:/Inetpub/wwwroot/Calypso/test.rtf";
//Custom format at the indenting of the output document by using an XmlTextWriterXmlTextWriter writer =
new XmlTextWriter( outPath, System.Text.Encoding.UTF8 );writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
transform.Transform( doc,
null, writer, null );RateMyEverything
PhaedoHD
Member
436 Points
156 Posts
Re: XSL, rtf and html
Nov 29, 2005 12:10 AM|LINK
I figured it out. You have to add a line writer.close() (which by the way is not on the MSDN example script)
RateMyEverything