Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > loading a single xml file with different stylesheets

Reply
Thread Tools

loading a single xml file with different stylesheets

 
 
jim
Guest
Posts: n/a
 
      07-23-2007
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"
xmlnssl="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"
xmlnssl="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>
 
Reply With Quote
 
 
 
 
Wizfrog
Guest
Posts: n/a
 
      07-24-2007
It is fairly simple with an XSL transform in Javascript.

Here is a very good example of what you can do, with multiple XSL
stylesheets, or one stylesheet with multiple templates to use to
transform the same XML document.


http://www.perfectxml.com/articles/x...MSXML.asp?pg=2

Good luck

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS stylesheets not loading in IE or firefox on XP SP2 Rschen7754 Computer Support 6 09-18-2009 02:22 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Dynamically loading stylesheets =?Utf-8?B?QWxhbiBMYW1iZXJ0?= ASP .Net 3 11-24-2004 12:07 AM
using multiple stylesheets with 1 xml file steve XML 4 12-03-2003 10:03 AM
Loading different stylesheets for different browsers Andries HTML 5 09-09-2003 07:47 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57