loading a single xml file with different stylesheets

J

jim

Hi

How can I load a different stylesheet depending on the html link I click
to output the same xml file?

I want to click on either the 'simple' or 'detailed' link and my xml
file is output using a stylesheet designed for that link.

At the moment I can only output one by linking to the stylesheet inside
the xml file.

Any ideas?




===============
data_movies.xml
===============

<?xml version="1.0"?>
<?xml:stylesheet type = "text/xsl" href = "list_detailed.xsl"?>
<data>
<record timestamp="7/23/2007 1:47:17
PM"><movie>trainspotting</movie><genre>drama</genre><rating>5</rating></record>
<record timestamp="7/23/2007 1:47:17
PM"><movie>unforgiven</movie><genre>western</genre><rating>4</rating></record>
<record timestamp="7/23/2007 1:47:17
PM"><movie>scarface</movie><genre>ganster</genre><rating>5</rating></record>
<record timestamp="7/23/2007 1:47:17 PM"><movie>the godfather part
I</movie><genre>ganster</genre><rating>5</rating></record>
<record timestamp="7/23/2007 1:47:17 PM"><movie>the
departed</movie><genre>action</genre><rating>4</rating></record>
</data>




=================
list_detailed.xsl
=================

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">

<html>

<head>

<link rel="stylesheet" type="text/css" href="mystyle.css" />

<title>Results</title>

</head>

<body>

<table>

<col width="50%"/>
<col width="40%"/>
<col width="10%"/>

<tr>
<th class="head">Title</th>
<th class="head">Genre</th>
<th class="head">Rating</th>
</tr>

<xsl:for-each select="data/record">
<xsl:sort select="movie"/>

<tr>
<td><xsl:value-of select="movie"/></td>
<td><xsl:value-of select="genre"/></td>
<td><xsl:value-of select="rating"/></td>
</tr>

</xsl:for-each>

</table>

<p class = "back"><a href = "index.html">Add Movie</a></p>

</body>
</html>


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




===============
list_simple.xsl
===============

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">

<html>

<head>

<link rel="stylesheet" type="text/css" href="mystyle.css" />

<title>Results</title>

</head>

<body>

<table>

<col width="100%"/>

<tr>
<th class="head">Title</th>
</tr>

<xsl:for-each select="data/record">
<xsl:sort select="movie"/>

<tr>
<td><xsl:value-of select="movie"/></td>
</tr>

</xsl:for-each>

</table>

<p class = "back"><a href = "index.html">Add Movie</a></p>

</body>
</html>


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top