Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2005, 06:50 AM
Registered User
 
Join Date: Apr 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display table in CSS via XSLT

Hi I am having trouble displaying a table in my webpage using XSLT.
My XSL template seems fine and displays the tabular data but I am unsure how to display it in a div tag? Any ideas?
*********xsl code**********
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template match="/">
        <html>
        <head>
        <title>Images in XSLT</title>
        <style>
                table {table-layout: auto; text-align:left; margin-left: auto; margin-right: auto;}
                td, th {border:1px single silver; padding:5px; width:15%px;}
                p { font-family:Verdana; font-size:10px; color:silver;margin-bottom;0px;}

        </style>
        </head>
        <body>
        <center>
        <h3>Carp Stuff limited</h3>

            <table border = "1">
            <xsl:for-each select="carpstuff/tackleitem">
                <xsl:sort select="itemname" data-type="text" />
                    <tr>
                    <td>
                    <xsl:apply-templates select="image" />
                    </td>
                    <td>
                    Item Name:<xsl:value-of select="itemname" /><br />
                    Brand Name: <xsl:value-of select="brandname" /><br />
                    <p>Catalogue Number:<xsl:value-of select="catalogueref" /><br />
                    Comments: <xsl:value-of select="comments" /><br />
                    <xsl:apply-templates select="cost" />
                    </p>
                    </td></tr>
            </xsl:for-each>
        </table>
        </center>
        </body>
        </html>
    </xsl:template>

    <xsl:template match="image">
        <img>
                <xsl:attribute name="src">
                        <xsl:value-of select="." />
                </xsl:attribute>
                <xsl:attribute name="width">
                        60
                </xsl:attribute>
        </img>
    </xsl:template>

    <xsl:template match="itemname">
            <p>
            <xsl:attribute name="style">
                    font-family:Verdana;font-size:10pt;color:silver;
            </xsl:attribute>
            <xsl:value-of select="." />
            </p>
    </xsl:template>

    <xsl:template match="cost">
            <p>
            <xsl:choose>
            <xsl:when test=". &gt; 80.00">
                    <xsl:attribute name="style">
                            color:maroon;
                    </xsl:attribute>
                    cost: £<xsl:value-of select="." /> (Expensive!)
            </xsl:when>
            <xsl:when test=". &lt; 79.99">
                    <xsl:attribute name="style">
                            color:green;
                    </xsl:attribute>
                    cost: £<xsl:value-of select="." /> (Good value!)
            </xsl:when>
            </xsl:choose>
            </p>
    </xsl:template>
</xsl:stylesheet>

*******html code*********
<script type="text/javascript">

// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("carpstuff.xml")

// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("carpstuff.xsl")

</script>
<title>XML XSLT</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="stylesheet/stylesheet.css" type="text/css">
</head>
<body>
<table width="753" top-margin="10" border="0" cellpadding="0" cellspacing="0" align="center">

<div class="container">
<div><img src="images/topimage.gif"></div>
<div class="myinfo">Greig Bosworth - Interactive Multimedia Student - Wolverhampton University - Student # 0063808</div>
<div><img src="images/leftimage.gif"></div>

        <div class="menucontainer">
            <div class="menuhead">Menu</div>
                <div class="buttonpos">
                <div class="buttons1"><a href="index.htm">{ XML }</a></div>
                <div class="buttons1"><a href="xml.htm">{ Data Islands }</a></div>
                <div class="buttons1"><a href="xslt.htm">{ XSLT }</a></div>
                <div class="buttons1"><a href="RSSFeeds.htm">{ RSS Feeds }</a></div>
                </div>
        </div>
<div class="textcontainer">
    <div class="texthead">XML</div>
        <div class="maintxt">
        <div "maintxtscroll">
<script type="text/javascript">
document.write(xml.transformNode(xsl))
</script>


</div>
    </div>
      <div class="copyright"><a href="index.htm">Home</a> |<a href="contact.htm">
        Contact</a> |<a href="portfolio.htm"> Portfolio </a> </div>
    </div>
</div>
&copy; Greig Bosworth 2005
</table>
</body>
</html>

Any help would be greatly appreciated.
Thanx
Greig.......








 
Old April 8th, 2005, 07:46 AM
Registered User
 
Join Date: Apr 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

P.S I forgot to say that I needed to display the table in the
div(<div class="textcontainer">)
Hopefully this makes more sense.

Greig.........






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply CSS to XSLT file??? rakesh XSLT 1 July 25th, 2008 03:20 AM
Scrolling table with CSS: Almost there! asearle XSLT 1 November 24th, 2007 10:13 AM
CSS Float Display Problem socoolbrewster CSS Cascading Style Sheets 12 October 20th, 2005 07:22 AM
Link Display Prob using CSS in IE6 / Firefox socoolbrewster CSS Cascading Style Sheets 3 September 7th, 2005 11:07 AM
xml xslt css structured web site mlaba XSLT 0 September 17th, 2004 07:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.