Home arrow XML arrow Page 3 - Designing Your Own Reporting Service: A Web Service to Convert XML to HTML Using XSL
XML

Designing Your Own Reporting Service: A Web Service to Convert XML to HTML Using XSL


This article guides you in developing a web service which converts a given XML string to HTML based on XSL file available at server side.

Author Info:
By: Jagadish Chaterjee
Rating: 4 stars4 stars4 stars4 stars4 stars / 11
December 19, 2005
TABLE OF CONTENTS:
  1. · Designing Your Own Reporting Service: A Web Service to Convert XML to HTML Using XSL
  2. · Developing the XML Web Service
  3. · Developing the XML Web Service continued
  4. · Defining the XSLT
  5. · Executing and testing the XML Web Service
  6. · Understanding the web service
  7. · Improvements to the solution

print this article
SEARCH DEVARTICLES

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();
                  resolver.Credentials =
System.Net.CredentialCache.DefaultCredentials;
                 
                  // Load the stylesheet.
                  string sXSLLocation = GetXSLLocation();
                  xslt.Load( sXSLLocation );
                 
 
                  // Load the XML string.
                  XmlDataDocument xmlDoc = new XmlDataDocument();
                  xmlDoc.XmlResolver = resolver;
                  xmlDoc.LoadXml(sXMLSource);
 
                  // 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
0
                  stream.Flush();
                  stream.Position = 0;
 
                  // Create a StreamReader to Read the Stream and Return
the String
                  System.IO.StreamReader sr = new System.IO.StreamReader
(stream);
                  return sr.ReadToEnd();
            }

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 Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials