Home
> Uncategorized > XSL stylesheet for displaying serialized datasets
XSL stylesheet for displaying serialized datasets
A utility I wrote some time ago http://www.webtropy.com/articles/art22-SQLCache.asp?SQL%20Server%20Performance for increasing SQL server (repeat) performance using XML caching used XMLSerializer to create XML files which were serialized versions of Datasets returned from SQL server.
I was looking for an easy way to display the contents of these files, without sifting through XML. I decided to have a look at writing a generic XSL style sheet to view these serialized datasets. First, I add a line to the top of the xml file:
<?xml-stylesheet type="text/xsl" href="dataset.xsl"?>
where dataset.xsl is:
<?xml version=’1.0′?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<xsl:for-each select="DataSet/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element">
<td><b><xsl:value-of select="@name"/></b></td>
</xsl:for-each>
</tr>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<xsl:for-each select="DataSet/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/xs:element">
<td><b><xsl:value-of select="@name"/></b></td>
</xsl:for-each>
</tr>
<xsl:for-each select="/DataSet/diffgr:diffgram/NewDataSet/*">
<tr>
<xsl:for-each select="*">
<td><xsl:value-of select="." /></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<tr>
<xsl:for-each select="*">
<td><xsl:value-of select="." /></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback