Home arrow XML arrow Page 2 - 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
(Page 2 of 7 )

Create a new Web Service project (with respect to C#) using Visual Studio.NET 2003 Enterprise Architect and make modifications to your “web.config” file as follows:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
    <appSettings>
            <add key="XSLLocation" value="c:\inetpub\wwwroot\WSXML2HTML\
Sample.xsl
" />
      </appSettings>
  <system.web>

Open your “XML2HTML.asmx.cs” (I renamed “Service1.*” to “XML2HTML.*”) and make modifications to your service as follows.

Before proceeding further, you need to remove (or comment) all the statements related to the “HelloWorld” method (as it is intended only for demonstration). 

Start with a new method “BuildHTMLString” as follows:

[WebMethod(Description="Builds an HTML string from XML.")]
            public string BuildHTMLString(string XML)
            {
                  return GenerateHTMLString(XML);
            }

Within the above method, no processing really exists.  Let us add one more method as follows:

private string GetXSLLocation()
            {
                  //Get XSL location from config file
                  string sXSLLocation = ConfigurationSettings.AppSettings.Get("XSLLocation");
                  return sXSLLocation;
            }

The above method simply gets the XSL file path available within the “web.config” file.


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