home *** CD-ROM | disk | FTP | other *** search
/ 11 Top Anwendungen / CD_ROM_MAGAZIN.iso / MoneyMethod-Demo / Beispiel / source / XML / tabbody.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2000-05-29  |  6.4 KB  |  161 lines

  1. <xsl:stylesheet
  2.   version="1.0"
  3.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4.   xmlns:xt="http://www.jclark.com/xt">
  5. <xsl:output method="html"/>
  6.  
  7. <xsl:template match="colnames">
  8.    <xsl:element name="tr" use-attribute-sets="header-style">
  9.      <xsl:apply-templates select="colname[position()=$titlecol]"/>
  10.      <xsl:apply-templates select="colname[position()=$pricecol]"/>
  11.      <xsl:variable name="props"
  12.   select="document("styles.xml")//paramgroup[@name="header"]"/>
  13.  
  14.   <xsl:element name="th">
  15.   <xsl:element name="font" use-attribute-sets="header-font-style">
  16.      <xsl:call-template name="apply-font-styles-using-path">
  17.         <xsl:with-param name="path" select="$props"/>
  18.         <xsl:with-param name="content" select="string("Bestellung")"/>
  19.     </xsl:call-template>
  20.  </xsl:element></xsl:element>
  21.   </xsl:element>
  22. </xsl:template>
  23.  
  24. <xsl:template match="colname">
  25.  
  26.    <xsl:variable name="props"
  27.   select="document("styles.xml")//paramgroup[@name="header"]"/>
  28.  
  29.  <xsl:element name="th" use-attribute-sets="header-style">
  30.  <xsl:element name="font" use-attribute-sets="header-font-style">
  31.  <xsl:variable name="content"> <!-- content content content -->
  32.      <xsl:value-of select="."/>
  33.  </xsl:variable>
  34.      <xsl:call-template name="apply-font-styles-using-path">
  35.         <xsl:with-param name="path" select="$props"/>
  36.         <xsl:with-param name="content" select="$content"/>
  37.     </xsl:call-template>
  38.  </xsl:element></xsl:element>
  39.  
  40. </xsl:template>
  41.  
  42. <!--
  43.                 <xsl:choose>
  44.                     <xsl:when test="position()=$isbncol">
  45.                         <xsl:text>isbn</xsl:text>
  46.                     </xsl:when>
  47.                     <xsl:when test="position()=$pricecol">
  48.                         <xsl:text>price</xsl:text>
  49.                     </xsl:when>
  50.                     <xsl:when test="position()=$titlecol">
  51.                         <xsl:text>title</xsl:text>
  52.                     </xsl:when>
  53.                 </xsl:choose>
  54. -->
  55.  
  56. <xsl:template match="row">
  57.   <xsl:element name="tr" use-attribute-sets="row-style">
  58.         <xsl:for-each select="cell[position()=$isbncol]">
  59.            <xsl:call-template name="process-cell">
  60.               <xsl:with-param name="celltype">isbn</xsl:with-param>
  61.           </xsl:call-template>  <!-- process-cell -->
  62.         </xsl:for-each>
  63.         <xsl:for-each select="cell[position()=$titlecol]">
  64.            <xsl:call-template name="process-cell">
  65.               <xsl:with-param name="celltype">title</xsl:with-param>
  66.           </xsl:call-template>  <!-- process-cell -->
  67.         </xsl:for-each>
  68.         <xsl:for-each select="cell[position()=$pricecol]">
  69.            <xsl:call-template name="process-cell">
  70.               <xsl:with-param name="celltype">price</xsl:with-param>
  71.           </xsl:call-template>  <!-- process-cell -->
  72.         </xsl:for-each>
  73.  
  74.         <td align="center">
  75.         <input size="5" type="text" name="{concat("quantity",@number)}"
  76.             onblur="JavaScript:ChangeTxt(this, sel);"/>
  77.         <input type="hidden" name="{concat("num",@number)}"   value="{$max-items}"/>
  78.         <input type="hidden" name="{concat("index",@number)}" value="{@number}"/>
  79.  
  80.         </td>
  81.   </xsl:element>
  82. </xsl:template>
  83.  
  84.  
  85. <xsl:template name="process-cell">
  86. <xsl:param name="celltype"/>
  87.  
  88.    <!-- number of parent row in table -->
  89.    <xsl:variable name="rowpos" select="ancestor::row/@number"/>
  90.  
  91.    <xsl:variable name="catpos">   <!-- number of parent row in table -->
  92.           <xsl:number count="//category"/>
  93.    </xsl:variable>
  94.  
  95.    <xsl:variable name="props"
  96.   select="document("styles.xml")//paramgroup[@name="rows"]"/>
  97.  
  98.    <xsl:if test="$celltype!="isbn"">
  99.  
  100.    <xsl:variable name="content"> <!-- content content content -->
  101.      <xsl:choose>  <!-- if need a link to card in this column -->
  102.         <xsl:when test="$celltype="title"">
  103.           <xsl:element name="td" use-attribute-sets="title-align">
  104.             <xsl:attribute name="width">70%</xsl:attribute>
  105.         <xsl:element name="font" use-attribute-sets="row-font-style">
  106.         <a href="{concat ('card', ancestor::row/@number, '.htm')}">
  107.          <xsl:value-of select="."/>
  108.         </a>
  109.     </xsl:element>
  110.     </xsl:element>
  111.        </xsl:when>
  112.        <xsl:otherwise>
  113.         <xsl:element name="td" use-attribute-sets="price-align">
  114.     <xsl:element name="font" use-attribute-sets="row-font-style">
  115.         <xsl:value-of select="."/>
  116.     </xsl:element>
  117.     </xsl:element>
  118.        </xsl:otherwise>
  119.      </xsl:choose>   <!-- end if need a link to card in this column -->
  120.     </xsl:variable>  <!-- content content content -->
  121.  
  122.     <xsl:call-template name="apply-font-styles-using-path">
  123.         <xsl:with-param name="path" select="$props"/>
  124.         <xsl:with-param name="content" select="$content"/>
  125.     </xsl:call-template>
  126.  
  127.     <input type="hidden" name="{concat ($celltype,$rowpos)}" value="{current()}"/>
  128.    </xsl:if>
  129.  
  130.     <xsl:if test="$celltype="isbn"">
  131.        <input type="hidden" name="{concat ($celltype,$rowpos)}" value="{current()}"/>
  132.     </xsl:if>
  133.  
  134.     <xsl:if test="$celltype="title"">
  135.         <input type="hidden" name="{concat ("link", $rowpos)}" value="{concat ('card', ancestor::row/@number, '.htm')}"/>
  136.     </xsl:if>
  137.  
  138. </xsl:template>
  139.  
  140. <xsl:template name="tabbody">
  141.   <xsl:param name="count"/>        <!-- starting row number -->
  142.   <xsl:param name="splitcount"/>   <!-- number of rows in each table -->
  143.  
  144.        <xsl:variable name="rows"><xsl:number count="//row"/></xsl:variable>
  145.        
  146.        <script><xsl:text disable-output-escaping="yes">if (netscape()) document.write("<table border='0' bgcolor='black' align='</xsl:text> 
  147.     <xsl:value-of select="$table-align"/>
  148.      <xsl:text disable-output-escaping="yes">' cellspacing='1' cellpadding='0'><tr><td>");</xsl:text></script>
  149.        <xsl:element name="table" use-attribute-sets="table-style">
  150.        <tbody>
  151.        <form action="" name="sel" method="post">
  152.          <xsl:apply-templates select="//colnames"/>
  153.          <xsl:apply-templates select="row[$count+$splitcount>position() and position()>=$count]"/>
  154.        </form>
  155.  
  156.        </tbody>
  157.        </xsl:element>  <!--table -->
  158.        <script><xsl:text disable-output-escaping="yes">if (netscape()) document.write("<\/tr><\/td><\/table>");</xsl:text></script>
  159. </xsl:template>
  160.  
  161. </xsl:stylesheet>