473,324 Members | 2,400 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,324 software developers and data experts.

simple rdf to html doesn't work

I have the following feed which I want to convert to html:
http://www.heise.de/newsticker/heise.rdf but it does not work, I only see
the html elements empty as if it found no elements in the xml file, whereas
the feed http://www.golem.de/rss.php?feed=RSS1.0 works perfectly although I
annot see any difference in the file structure.
This is my xsl file:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns="http://www.w3.org/1999/xhtml"

<xsl:output method="html" />
<xsl:template match="/rdf:RDF">
<html>
<head>
<title>
<xsl:value-of select="/rdf:RDF/rss:channel/rss:title" />
</title>
</head>
<body>
<h2>
<xsl:value-of select="/rdf:RDF/rss:channel/rss:title" />
</h2>
<a href="{rss:channel/rss:link}">
<xsl:value-of select="rss:channel/rss:link" />
</a>
<br />
<xsl:apply-templates select="rss:channel/rss:image" />
<br />
<xsl:value-of select="rss:channel/rss:date" />
<br />
<xsl:value-of select="rss:channel/rss:description" />
<br />
<xsl:apply-templates select="rss:item" />
</body>
</html>
</xsl:template>
<xsl:template match="rss:image">
<img src="{@rdf:resource}" />
</xsl:template>
<xsl:template match="rss:item">
<h3>
<a href="{rss:link}">
<xsl:value-of select="rss:title" />
</a>
</h3>
<xsl:value-of select="rss:description" disable-output-escaping="yes" />
<font size="-1" color="808080">
<br />
<xsl:value-of select="rss:link" />
<br />
<xsl:value-of select="rss:date" />
</font>
</xsl:template>
</xsl:stylesheet>
Nov 12 '05 #1
4 1458
* cody wrote in microsoft.public.dotnet.xml:
I have the following feed which I want to convert to html:
http://www.heise.de/newsticker/heise.rdf but it does not work, I only see
the html elements empty as if it found no elements in the xml file, whereas
the feed http://www.golem.de/rss.php?feed=RSS1.0 works perfectly although I
annot see any difference in the file structure.
The namespaces are different. With
xmlns:rss="http://purl.org/rss/1.0/"
this declaration you bind the namespace "http://purl.org/rss/1.0/" to
the prefix "rss", so the
<xsl:value-of select="/rdf:RDF/rss:channel/rss:title" />


rss:channel node test would select "channel" elements in the
"http://purl.org/rss/1.0/" namespace. In the Heise RSS feed the
"channel" element is in the http://my.netscape.com/rdf/simple/0.9/
namespace, and

{"http://purl.org/rss/1.0/", "channel"}
{"http://my.netscape.com/rdf/simple/0.9/", "channel"}

are different elements. See

http://msdn.microsoft.com/library/en...ml05202002.asp
http://www.rpbourret.com/xml/NamespacesFAQ.htm
http://msdn.microsoft.com/msdnmag/issues/01/07/xml/
http://www.google.com/search?q=xml+namespaces

for details.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Nov 12 '05 #2
OK I understand. As I read in your links, the same prefix cannot be in more
than one namespace at the same time.But how can I solve this issue? I do not
want to create 2 xsl files differing only in the namespace declaration.
"Bjoern Hoehrmann" <bj****@hoehrmann.de> schrieb im Newsbeitrag
news:43****************@news.bjoern.hoehrmann.de.. .
* cody wrote in microsoft.public.dotnet.xml:
I have the following feed which I want to convert to html:
http://www.heise.de/newsticker/heise.rdf but it does not work, I only see
the html elements empty as if it found no elements in the xml file,
whereas
the feed http://www.golem.de/rss.php?feed=RSS1.0 works perfectly although
I
annot see any difference in the file structure.


The namespaces are different. With
xmlns:rss="http://purl.org/rss/1.0/"


this declaration you bind the namespace "http://purl.org/rss/1.0/" to
the prefix "rss", so the
<xsl:value-of select="/rdf:RDF/rss:channel/rss:title" />


rss:channel node test would select "channel" elements in the
"http://purl.org/rss/1.0/" namespace. In the Heise RSS feed the
"channel" element is in the http://my.netscape.com/rdf/simple/0.9/
namespace, and

{"http://purl.org/rss/1.0/", "channel"}
{"http://my.netscape.com/rdf/simple/0.9/", "channel"}

are different elements. See

http://msdn.microsoft.com/library/en...ml05202002.asp
http://www.rpbourret.com/xml/NamespacesFAQ.htm
http://msdn.microsoft.com/msdnmag/issues/01/07/xml/
http://www.google.com/search?q=xml+namespaces

for details.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

Nov 12 '05 #3
* cody wrote in microsoft.public.dotnet.xml:
OK I understand. As I read in your links, the same prefix cannot be in more
than one namespace at the same time.But how can I solve this issue? I do not
want to create 2 xsl files differing only in the namespace declaration.


You could change the XPath expressions to consider multiple namespaces,
instead of rss:channel you could use *[local-name() = 'channel' and
(namespace-uri() = '...' or namespace-uri() = '...')] but that's not
really a good approach here. You could also use http://feedparser.org/
to parse RSS and probably even convert between formats. Otherwise I
guess using multiple XSLT documents is the best option here.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Nov 12 '05 #4
"Bjoern Hoehrmann" <bj****@hoehrmann.de> schrieb im Newsbeitrag
news:42***************@news.bjoern.hoehrmann.de...
* cody wrote in microsoft.public.dotnet.xml:
OK I understand. As I read in your links, the same prefix cannot be in
more
than one namespace at the same time.But how can I solve this issue? I do
not
want to create 2 xsl files differing only in the namespace declaration.


You could change the XPath expressions to consider multiple namespaces,
instead of rss:channel you could use *[local-name() = 'channel' and
(namespace-uri() = '...' or namespace-uri() = '...')] but that's not
really a good approach here.


That is cool thank you :)
Nov 12 '05 #5

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

Similar topics

16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
7
by: J. Hall | last post by:
Hi dudes, Got a simple webpage, with three numeric text input boxes, the idea being that the user is asked to insert percentages of their business around the world... UK, Europe, Other ...
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
5
by: Le, Thanh-Nhan | last post by:
Hi, I want to send a simple mail with C#. I have tried the following, but they don't work: - some solutions on CodeProject websites. - shellExecute(mailto:xxx@yyy.com?subject=aaa&body=bbb). ...
0
by: pepsi | last post by:
Hello, I would suggest a simple div tag... you could assign it a id and runat server. It should work. pepsi >-----Original Message----- >Hi gang. I tried posting this under a different...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
10
by: serge calderara | last post by:
Dear all, I need to build a web application which will contains articles (long or short) I was wondering on what is the correct way to retrive those article on web page. In orther words, when...
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
3
by: Joe | last post by:
Hi, I have a simple thing I need to do but just doesn't work in VB.NET. I have a string with HTML code and I want to load it into a HTMLDocument object or something similiar to it so I can...
7
by: Trickynick1001 | last post by:
Hi, a newbie here. I don't have a real firm grasp on the idea of Javascript, as I'm used to programming in Qbasic and C. I'm not used to OOP. Anyway, I really don't have any idea what the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.