[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: MSXML 4 - RowSetSchema XML

Subject: Re: MSXML 4 - RowSetSchema XML
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Tue, 17 Feb 2004 09:24:49 +0000
rowset schema
This is a transform I use for showing information. It's designed to produce an html table from an MS ado row set saved as xml. It's not very sophisticated but you can probably improve it:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'
exclude-result-prefixes="s dt rs z">

<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:variable name="fieldData" select="xml/s:Schema/s:ElementType/s:AttributeType[not(@rs:hidden)]"/>
<xsl:variable name="columnCount" select="count($fieldData)"/>
<xsl:variable name="columnWidth" select="floor(100 div $columnCount)"/>
<div id="divMain" style="margin:0px">
<table border="1" width="100%" cols="{$columnCount}">
<thead>
<tr style="font-size:9pt;background-color:#0000cc;color:#ffffff">
<xsl:apply-templates select="$fieldData">
<xsl:with-param name="columnWidth" select="$columnWidth"/>
</xsl:apply-templates>
</tr>
</thead>
<xsl:apply-templates select="xml/rs:data">
<xsl:with-param name="fieldData" select="$fieldData"/>
<xsl:with-param name="columnCount" select="$columnCount"/>
<xsl:with-param name="columnWidth" select="$columnWidth"/>
</xsl:apply-templates>
</table>
<br/>
</div>
</xsl:template>
<xsl:template match="s:AttributeType">
<xsl:param name="columnWidth"/>
<th width="{$columnWidth}%">
<xsl:choose>
<xsl:when test="@rs:name">
<xsl:value-of select="@rs:name"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</th>
</xsl:template>
<xsl:template match="rs:data">
<xsl:param name="fieldData"/>
<xsl:param name="columnCount"/>
<xsl:param name="columnWidth"/>
<tbody style="color:#0000cc;font-size:9pt;">
<xsl:apply-templates>
<xsl:with-param name="fieldData" select="$fieldData"/>
<xsl:with-param name="columnWidth" select="$columnWidth"/>
</xsl:apply-templates>
</tbody>
</xsl:template>
<xsl:template match="z:row">
<xsl:param name="fieldData"/>
<xsl:param name="columnWidth"/>
<xsl:variable name="currentRow" select="."/>
<tr style="font-size:9pt;">
<xsl:for-each select="$fieldData">
<td width="{$columnWidth}%">
<xsl:attribute name="align">
<xsl:choose>
<xsl:when test="s:datatype/@dt:type = 'string'">
<xsl:value-of select="'left'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'right'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:variable name="currentData" select="$currentRow/@*[name() = current()/@name]"/>
<xsl:choose>
<xsl:when test="$currentData != ''">
<xsl:choose>
<xsl:when test="s:datatype/@rs:dbtype = 'currency'">
<xsl:value-of select="format-number($currentData, '#,##0')"/>
</xsl:when>
<xsl:when test="s:datatype/@rs:dbtype = 'timestamp'">
<xsl:value-of select="concat(substring($currentData, 9, 2), '/', substring($currentData, 6, 2), '/', substring($currentData, 1, 4))"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'&#xa0;'"/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>




Joe

_________________________________________________________________
Sign-up for a FREE BT Broadband connection today! http://www.msn.co.uk/specials/btbroadband



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.