| | |
XSLT Help
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Feb 2009
Posts: 27
Reputation:
Solved Threads: 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:
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
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:
xml Syntax (Toggle Plain Text)
<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
Last edited by Tamir09; Jul 2nd, 2009 at 2:11 am.
•
•
Join Date: Feb 2009
Posts: 27
Reputation:
Solved Threads: 0
Just for those who might need the solution for this, I have it as:
xml Syntax (Toggle Plain Text)
<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>
![]() |
Similar Threads
- ASP.NET - session objects Problem (ASP.NET)
- Error loading stylesheet: Parsing an XSLT stylesheet failed (RSS, Web Services and SOAP)
- XSLT - inserting new elements (XML, XSLT and XPATH)
- How to transform XML to XSLT (HTML and CSS)
- XSLT weird problem... [urgent] (RSS, Web Services and SOAP)
- XSLT code doesn't seem to work!! (XML, XSLT and XPATH)
- Transforming XML with XSLT (HTML and CSS)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Parse JavaScript Variable to a XSLT Variable
- Next Thread: xslt help for links in html
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





