Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MotleyFool RDF transform with XSL problem 1

Status
Not open for further replies.

ChainsawJoe

Programmer
Dec 5, 2000
154
GB
I'm attempting to simply parse the rdf file provided by financial website MotleyFool - - to have the "item" contents appear in a <ul> in the form:
<ul>
<li><a href="link">title</a</li>
...
...
</ul>

This should be o so easy, but I can't for the life of me get it to work. Please can someone help?!

This is the RDF file from the website:
Code:
<?xml version="1.0"?>
<!--Usage of this file constitutes agreement with The Motley Fool UK terms of use found at [URL unfurl="true"]http://www.fool.co.uk/help/headlines/headlines.htm#tos.[/URL] Please direct questions to headlines@fool.co.uk-->
<rdf:RDF xmlns:rdf="[URL unfurl="true"]http://www.w3.org/1999/02/22-rdf-syntax-ns#"[/URL] xmlns="[URL unfurl="true"]http://my.netscape.com/rdf/simple/0.9/">[/URL]
	<channel>
		<title>The Motley Fool UK</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk</link>[/URL]
		<description>To Educate, Amuse, and Enrich</description>
	</channel>
	<image>
		<title>The Motley Fool UK</title>
		<url>[URL unfurl="true"]http://www.fool.co.uk/art/buttons/88x31uk.gif</url>[/URL]
		<link>[URL unfurl="true"]http://www.fool.co.uk/</link>[/URL]
	</image>
	<item>
		<title>Comment: The Next 12,100% Return</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050831c.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Comment: Don&#39;t Fall For This Card Trick!</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050831d.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Comment: High Yield Tips From Top City Investors</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050831b.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>U.S. Shares: Here&#39;s Your Hammer</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/stockideas/2005/si050831.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Fool School: Balance Sheet Basics: Part I</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/school/2005/sch050831.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Comment: Create A Comfort Zone Of Cash</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050830a.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Comment: Home Loans From Heaven - And Hell!</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050830d.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Comment: How To Spot A Scam</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050830e.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Comment: Why You Shouldn&#39;t Keep Your Debts Secret</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/comment/2005/c050830c.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Fool&#39;s Eye View: Your Two-Minute Financial Health Check</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/news/foolseyeview/2005/fev050830c.htm?ref=foolwatch</link>[/URL]
	</item>
	<item>
		<title>Qualiport: The Best Customers For Your Shares</title>
		<link>[URL unfurl="true"]http://www.fool.co.uk/qualiport/2005/qualiport050830.htm?ref=foolwatch</link>[/URL]
	</item>
</rdf:RDF>

And I've tried too many different XSL file possibilities to start pasting them in. If anyone can help, please do!

many many many tia!

CJ

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Thank you! That FAQ was still a little confusing, but with the help of the faq and googling on default namespace rdf issues, I found which conbined with the faq ironed out the issues. The resulting xsl is this:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
	xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
	xmlns:rdf="[URL unfurl="true"]http://www.w3.org/1999/02/22-rdf-syntax-ns#"[/URL]
	xmlns:fool="[URL unfurl="true"]http://my.netscape.com/rdf/simple/0.9/">[/URL]
	
<xsl:template match="rdf:RDF"> 
<span class="boxList">
<ul>
	<xsl:apply-templates select="fool:item" />
</ul>
</span>
</xsl:template>

<xsl:template match="fool:item">
	<li>&#160;<a href="{fool:link}"><xsl:value-of select="fool:title"/></a></li>
</xsl:template>
</xsl:stylesheet>

Many thanks, Jon!

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top