xsl-list
[Top] [All Lists]

Re: how red ampersand from the xml file

2005-03-25 11:44:38
----- Original Message ----- From: "henry human" <henry_human(_at_)yahoo(_dot_)de>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, March 25, 2005 6:36 PM
Subject: Re: [xsl] how red ampersand from the xml file


yes,this s a good way!

Not sure if that was a yes to file request but here it is:

<?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, 14))" />
               </xsl:when>
             </xsl:choose>
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="' '" />
           </xsl:otherwise>
         </xsl:choose>
       </td>
     </xsl:for-each>
   </tr>
 </xsl:template>
</xsl:stylesheet>


Regards

Joe
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--