Designing Your Own Reporting Service: A Web Service to Convert XML to HTML Using XSL - Defining the XSLT
(Page 4 of 7 )
Create a new XSLT file within the same project with the name “sample.xsl”. Make certain that you need to modify the “web.config” file (as specified above), if you store the same file in a different path or with a different file name. Modify the content within the “sample.xsl” file, so that it looks exactly the same as the following:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:teletext="teletext.co.uk" version="1.0">
<xsl:template match="/">
<html>
<body>
<table border="1">
<theader>
<tr>
<th>Product ID</th>
<th>Product Name</th>
</tr>
</theader>
<tbody>
<xsl:for-each select="Products/Product">
<tr>
<td>
<xsl:value-of select="idproduct" />
</td>
<td>
<xsl:value-of select="productname" />
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
You can find the above XSL code in the “sample.xsl” file within the downloadable zip. If you are very new to XSL (and cannot understand the above), you will want to go through my previous article “Applying XSLT to XML Using ASP.NET”, which discusses almost the same type of XSL.
Next: Executing and testing the XML Web Service >>
More XML Articles
More By Jagadish Chaterjee