[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Converting xml data to html using xsl/xslt

Subject: RE: Converting xml data to html using xsl/xslt
From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx>
Date: Wed, 11 Feb 2004 14:58:05 -0800
convert xml to html table
You may want to start by laying out the html first so that you know what your end result should look like. Take a look at the file that your xsl is outputting, not rendered by a browser, and I think you will see what is happening more clearly.

Your template is matching the <slide> element. You have two slide elements in the slideshow, so you are getting two full copies of the html from your template. You probably want to start your match closer to the root

Here is a start for the xsl...

<xsl:template match="/slideshow">
  <table>
    <tr><th>data1</th><th>data2</th></tr>
    <xsl:for-each select="slide">
      <tr>
        <td><xsl:value-of select="data1"/></td>
        <td><xsl:value-of select="data2"/></td>
      </tr>
    </xsl:for-each>
  </table>
<xsl:template>

Hope this helps,
Josh

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Anna Bikkina
Sent: Wednesday, February 11, 2004 2:01 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Converting xml data to html using xsl/xslt


Hi,

I have to convert a xml file into html. The data in xml has to be represented 
as tables. I have to write a xsl stylesheet and use xslt for the 
tranformation.

My xml file looks like this.

<slideshow>
	<slide> 
		<data1> xx1 </data1>
		<data2> xx2 </data2>
	</slide>

	<slide> 
		<data1> yy1 </data1>
		<data2> yy2 </data2>
	</slide>
</slideshow>

My existing xsl looks like this
  <xsl:template match="slide">
        <html>
                <title> SOAP AND XML</title>
                <style type="text/css">
                    code {color: #808080;}
                </style>
                <body>
                        <table border="1">
                                <xsl:for-each select="*">
                                        <tr>
                                                <th><xsl:value-of 
select="name()"/></th>
                                                <td><xsl:apply-templates 
select="." mode="value"/></td>
                                        </tr>
                                </xsl:for-each>
                        </table>
                </body>
        </html>

  </xsl:template>

I am getting data in seperate tables instead of in seperate rows. 

The data should be in a html table with data1 and data2 as headers and xx1,xx2 
in the first row and yy1 and yy2 in the second row.

I am not able to write a xsl to get this.

Can someone please help me write one.

Thanks,
Anna.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.