0

Im trying to format my xslt form to a table that I have:

Horsepower-Electric Values
Revolutions Number of Disks
blank num 1 num 2 num 3
rev1 hpe1 hpe2 hpe3
rev2 hpe4 hpe5 hpe6
rev3 hpe7 hpe8 hpe9

And so far, Ive gotten the xslt form to come out somewhat similarly to that table, but the way its formatting just cant get fixed. I tried different ways, but I know Im missing something, and I cant figure out what. Heres the code for the xslt form:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">

<html>
      <body>
        <table border="2">
          <tr>
            <th colspan ="4" bgcolor="darkgrey">Horsepower-Electric Values</th>
          </tr>
          <tr>
            <th bgcolor="lightblue">Revolutions</th>
            <th colspan="7" bgcolor="tan">Number of Disks</th>
          </tr>
          <tr><xsl:for-each select="ArrayOfMyHPEData/MyHPEData">
            <td>
               <xsl:value-of select="n"/>
            </td>
          </xsl:for-each>
            </tr>
          <tr>
            <xsl:for-each select="ArrayOfMyHPEData/MyHPEData">
              <td>
                <xsl:value-of select="HPE"/>
              </td>
            </xsl:for-each>
          </tr>
          <xsl:for-each select="ArrayOfMyHPEData/MyHPEData">
            <tr>
               <td>
                <xsl:value-of select="Rev"/>
              </td>
              <!--<td>
                <xsl:value-of select="HPE"/>
              </td>   -->       
            </tr></xsl:for-each>
        </table>
      </body>
    </html>

  </xsl:template>
</xsl:stylesheet>

Does anyone know how I can fix this? Could it be the formatting problem is in my xml? Heres what the table is actually looking like when the xml combines with the xslt form.

HPEData.html

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Tamir09
0

Just for those who might need the solution for this, I have it as:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes"/>

  <xsl:key name="key-revolution" match="Rev" use="text()"/>
  <xsl:key name="key-number" match="n" use="text()"/>


  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates select="ArrayOfMyHPEData" />
      </body>
    </html>
  </xsl:template>

  <xsl:template match="ArrayOfMyHPEData">
    <table border="2">
      <tr>
        <th colspan ="8" bgcolor="darkgrey">Horsepower-Electric Values</th>
      </tr>
      <tr>
        <th bgcolor="lightblue">Revolutions</th>
        <th colspan="7" bgcolor="tan">Number of Disks</th>
      </tr>
      <xsl:call-template name="PrintNumbers" />
      <xsl:for-each select="MyHPEData/Rev[generate-id() = generate-id(key('key-revolution', text()))]">
        <xsl:variable name="rev" select="." />
        <tr>
          <td>
            <xsl:value-of select="$rev" />
          </td>
          <xsl:for-each select="/ArrayOfMyHPEData/MyHPEData/n[generate-id() = generate-id(key('key-number', text()))]">
            <td>
              <xsl:value-of select="/ArrayOfMyHPEData/MyHPEData[Rev = $rev and n = current()]/HPE"/>
            </td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>

  <xsl:template name="PrintNumbers">
    <tr>
      <td />
      <xsl:for-each select="MyHPEData/n[generate-id() = generate-id(key('key-number', text()))]">
        <td>
          <xsl:value-of select="."/>
        </td>
      </xsl:for-each>
    </tr>
  </xsl:template>
</xsl:stylesheet>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.