Designing Your Own Reporting Service: A Web Service to Convert XML to HTML Using XSL - Developing the XML Web Service continued
(Page 3 of 7 )
Now, let us proceed with the “GenerateHTMLString” method, which is usually called by “BuildHTMLString”.
private string GenerateHTMLString(string sXMLSource)
// Create the XslTransform.
XslTransform xslt = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver();
// Load the stylesheet.
string sXSLLocation = GetXSLLocation();
xslt.Load( sXSLLocation );
// Load the XML string.
XmlDataDocument xmlDoc = new XmlDataDocument();
xmlDoc.XmlResolver = resolver;
// Create the Stream to place the output.
Stream stream = new MemoryStream();
// Transform the file.
xslt.Transform(xmlDoc, null, stream, resolver);
// Remember to Flush the Stream and set the position to
stream.Position = 0;
// Create a StreamReader to Read the Stream and Return
System.IO.StreamReader sr = new System.IO.StreamReader
And thus, our coding (development) part is successfully finished. The next section helps you to build the solution and test it from within Visual Studio.NET IDE to your own satisfaction.
blog comments powered by