473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Can't separate XSL styles with multiple RSS feeds

Hi,

I have 2 xsl style sheets calling separate rss feeds and I use ASP to
display.

Problem is that the 1st xsl takes on the style of the 2nd xsl even
though they are different formats. I think I need to clear from memory
but not sure how. This is the code and sample outputs. They work great
on their own but when I call them both they display the same formats.
Thanks for any help.

news4.asp

<%
Function getXML(sourceFile)
dim styleFile
dim source, style
styleFile = Server.MapPath("news.xsl")

Dim xmlhttp
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "GET", sourceFile, false
xmlhttp.Send

set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.loadxml(xmlhttp.ResponseText)

set style = Server.CreateObject("Microsoft.XMLDOM")
style.async = false
style.load(styleFile)

getXML = source.transformNode(style)
set source = nothing
set style = nothing
End Function
%>
<html>

<%= getXML("http://syndication.boston.com/news?mode=rss_10?") %>

===========
news.xsl

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="*">
<table border="1" width="100%" align="center">
<tr><td valign="top" align="center" class="title" bgcolor="silver" >
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='channel']/*[local-name()='link']"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='channel']/*[local-name()='title']"/>
</a>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="*[local-name()='channel']/*[local-name()='lastBuildDate']"/>
</td></tr><tr><td valign="top" bgcolor="ghostwhite"
class="headlines"><font size="2">
<xsl:for-each select="//*[local-name()='item' and position() &lt;
10]">
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='link']"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='title']"/>
</a>
|
</xsl:for-each>
</font></td></tr>
</table>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

Output by itself:
http://www.eastonmass.com/forum/news4.asp

==========================================

Next feed: weather3.asp

<%
Function getXML(sourceFile)
dim styleFile
dim source, style
styleFile = Server.MapPath("weather3.xsl")

Dim xmlhttp
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "GET", sourceFile, false
xmlhttp.Send

set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.loadxml(xmlhttp.ResponseText)

set style = Server.CreateObject("Microsoft.XMLDOM")
style.async = false
style.load(styleFile)

getXML = source.transformNode(style)
set source = nothing
set style = nothing
End Function
%>
<html>
<%= getXML("http://www.rssweather.com/rss.php?config=&forecast=zandh&place=south+easton& state=ma&zipcode=02375&country=us&county=25005&zon e=MAZ017&alt=rss20a")
%>

=============
weather3.xsl

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="*">
<table border="1" width="100%" align="center">
<tr>
<td valign="top" align="center" class="title" bgcolor="silver">
<xsl:value-of select="*[local-name()='channel']/*[local-name()='title']"
/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
<xsl:value-of select="*[local-name()='channel']/*[local-name()='lastBuildDate']"
/>
</td>
</tr>
<tr>
<td valign="top" bgcolor="ghostwhite" class="headlines">
<ul>
<xsl:for-each select="//*[local-name()='item' and position() &lt;
13]">
<!--
<xsl:value-of select="*[local-name()='channel']/*[local-name()='title']"
/>
-->
<b>
<xsl:value-of select="*[local-name()='title']" />
:
</b>
<xsl:value-of select="*[local-name()='description']"
disable-output-escaping="yes" />
--
</xsl:for-each>
</ul>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>

===========================
output for weather3.asp
http://www.eastonmass.com/forum/weather3.asp

===========================
Calling them both:
testboth.asp

<!--#INCLUDE FILE="news4.asp" -->
<!--#INCLUDE FILE="weather3.asp" -->

==================
output for testboth.asp

http://www.eastonmass.com/forum/testboth.asp (here's the problem)

====================================
As you can see, the news feed takes on the attributes of the weather
feed which I don't want. Appreciate any help.
Jul 20 '05 #1
2 1946
bu***@yahoo.com (Burt Lewis) wrote in message news:<e7**************************@posting.google. com>...
Problem is that the 1st xsl takes on the style of the 2nd xsl even
though they are different formats. I think I need to clear from memory
but not sure how. This is the code and sample outputs. They work great
on their own but when I call them both they display the same formats.
Thanks for any help.


This is an ASP (and general coding style) problem, not an XSL problem.

Your ASP "testboth" is using the include mechanism to link in both ASP
fragments. This is a good idea, but the implementation isn'right.
Each include file declares a function called getXML() and then invokes
it, and the two functions are slightly different to render the two
different feeds. This won't work in ASP (or almost any programming
environment) - because the two functions have the same name, only one
of them can be "in scope" at the same time.

I suggest that you make the stylesheet a parameter to the function in
just the same way you've already done it for the feed source. Then
it'll work.

Alternatively, keep two functions but rename them as
getRSSAsHTML_TableStyle() and getRSSAsHTML_BlockStyle() or
something like that.

Neater code might be to use three include files instead of two. Put
the function declaration in one, and put the two calls to it in the
others. That way you can use the function whenever you want - you
might even just use the include file once and place the two calls (and
their feed / stylesheet URLs) directly into the page that calls them.
Jul 20 '05 #2
Bingo!

Thank you very much for your help that was exactly what I needed.
Everything works great now.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Motta | last post by:
Hi I'd like a function that searches through several RSS feeds, and generates a new feed with the results. Example:
0
by: milesd | last post by:
Hi, Rather new to MSXML4. I am parsing an XML data-stream over HTTP, and would like to know why I cannot parse XML nodes with multiple parameters. The XML and Code are below, BUT I would like...
7
by: codeslayer | last post by:
Greetings to everyone in ‘forum-land': I have a problem that has plaguing me to no end. It is a CSS-related question, and I have not seen this question posted anywhere in forums or through...
8
by: Ryan Stewart | last post by:
Is there a way to reset the style property of an HTML element to some default or to all empty values? I have a group of elements whose style settings may be changed arbitrarily at certain points in...
6
by: nboutelier | last post by:
Is it possible to apply multiple css styles to a textfield. Eg, if the value of the textfield is "foo bar" id like for 'foo' to be arial and 'bar' to be verdana. Or... id like for 'foo' to be...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
5
by: Peter Rilling | last post by:
Okay, the other day I was talking with someone about assemblies. He said something that I am not really sure about. He said that a DLL or EXE can contain more then one assembly (although the IDE...
3
by: spolsky | last post by:
hi, it is possible to apply multiple styles as shown in the following example. <STYLE TYPE="text/css"><!-- BODY { background-color:salmon; } P { margin-left:20px; } .clsCode {...
1
by: Keoki12 | last post by:
I am a real newbie when it comes to HTML and CSS programming, so please be patient with me. I have a table. In one cell, I want 3 different styles for the text: First Line: Bold, Red Second...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.