Altova Mailing List Archives
>xsl-list Archive Home
>Recent entries
>Thread Prev - [xsl] Table type output in text fromat in a xml file
[Thread Next]
RE: [xsl] Table type output in text fromat in a xml file
To:
Date: 12/27/2007 1:00:00 AM
Same idea, different stylesheet layout: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="test"> <table> <xsl:apply-templates select="testcase[1]" mode="header"/> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match="testcase" mode="header"> <tr> <xsl:apply-templates select="@*" mode="header"/> </tr> </xsl:template> <xsl:template match="testcase/@*" mode="header"> <th> <xsl:value-of select="name()"/> </th> </xsl:template> <xsl:template match="testcase"> <tr> <xsl:apply-templates select="@*"/> </tr> </xsl:template> <xsl:template match="testcase/@*"> <td> <xsl:value-of select="."/> </td> </xsl:template> </xsl:stylesheet> If you're just using the stylesheet once or twice for a small dataset that won't change much over time, Alice's stylesheet is a shorter and easier to implement. If you're going to be doing more with it and plan to change it over time, a stylesheet like the one above will be easier to change and maintain. ~ Scott -----Original Message----- From: Alice Wei [mailto:ajwei@xxxxxxxxxxx] Sent: Wednesday, December 26, 2007 6:46 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Table type output in text fromat in a xml file Hi, Rasha: If you just want to output it as a HTML table, you can create a table that shapes like what you described. <table> <tr> <td>Name</td> <td>Result</td> <td>Comment</td> </tr> <xsl:for-each select="test/textcase"> <tr> <td><xsl:value-of select="./@name"/></td> <td><xsl:value-of select="./@result"/></td> <td><xsl:value-of select="./@comment"/></td> </tr> </xsl:for-each> </table> Give it a shot. Good luck! Alice Wei MIS 2008 School of Library and Information Science Indiana University Bloomington ajwei@xxxxxxxxxxx 812-856-2659 Quoting rasha dwidar <rasha_dwidar@xxxxxxxxx>: > Hi All, > > I have xml file as mentioned below. I want to use xsl to display it > in text format. I want to present xml data in table in text format. > Is that possible? > > XML file > > <test> > <testcase name=" test001" result="failed" comment= "test failed"/> > <testcase name= "test001" result="failed" comment= "test failed" /> > <testcase name= "test001" result="passed" comment="test passed"/> > </test> > > I want to display it in text format like that. > > Name Result Comment > test001 failed test failed > test002 failed test failed > test003 passed test passed > > > I appreciate your help > > Rasha > > > > > > ________________________________________________________________________ ____________ > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs > > Alice Wei MIS 2008 School of Library and Information Science Indiana University Bloomington ajwei@xxxxxxxxxxx 812-856-2659
Disclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

