
March 18th, 2008, 02:21 PM
|
|
Contributing User
|
|
Join Date: Oct 2005
Posts: 111
 
Time spent in forums: 1 Day 3 h 23 m 43 sec
Reputation Power: 3
|
|
|
XSL Namespaces
Hi,
I'm trying to transform XML via XSLT, and I'm having trouble defining a feed namespace in the header.
This is the XML I'm dealing with, I've highlighted the relevant bits that I'm having trouble transforming:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss'
xmlns:media='http://search.yahoo.com/mrss/'
xmlns:yt='http://gdata.youtube.com/schemas/2007'
xmlns:gd='http://schemas.google.com/g/2005'>
<id>http://gdata.youtube.com/feeds/api/videos</id><updated>2008-03-18T10:22:18.983Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><title type='text'>YouTube Videos matching query: golf</title><logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo><link rel='alternate' type='text/html' href='http://www.youtube.com'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos?start-index=1&max-results=25&vq=gol'/>
<link rel='next' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos?start-index=26&max-results=25&vq=golf'/><author>
<name>YouTube</name><uri>http://www.youtube.com/</uri></author><generator version='beta' uri='http://gdata.youtube.com/'>YouTube data API</generator>
<openSearch:totalResults>126000</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage>
<entry><id>http://gdata.youtube.com/feeds/api/videos/zKcBTaTed0Q</id>
<published>2006-10-20T17:35:14.000-07:00</published><updated>2008-03-17T22:41:55.000-07:00</updated>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='golf'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='amazing'/>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='lucky'/>
<category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Sports' label='Sport'/>
<title type='text'>Amazing golf shot</title>
<content type='text'>Fuzzy Zoeller shows why its better to be lucky than good.</content>
<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=zKcBTaTed0Q'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/zKcBTaTed0Q/responses'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/zKcBTaTed0Q/related'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/zKcBTaTed0Q'/><author><name>winchesterz</name>
<uri>http://gdata.youtube.com/feeds/api/users/winchesterz</uri></author>
<media:group><media:title type='plain'>Amazing golf shot</media:title>
<media:description type='plain'>Fuzzy Zoeller shows why its better to be lucky than good.</media:description><media:keywords>amazing, golf, lucky
</media:keywords><yt:duration seconds='37'/>
<media:category label='Sport' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Sports
</media:category><media:content url='http://www.youtube.com/v/zKcBTaTed0Q' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='37' yt:format='5'/>
<media:content url='rtsp://rtsp2.youtube.com/ChoLENy73wIaEQlEd96kTQGnzBMYDSANFEgGDA==/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='37' yt:format='1'/>
<media:content url='rtsp://rtsp2.youtube.com/ChoLENy73wIaEQlEd96kTQGnzBMYESARFEgGDA==/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='37' yt:format='6'/>
<media:player url='http://www.youtube.com/watch?v=zKcBTaTed0Q'/>
<media:thumbnail url='http://img.youtube.com/vi/zKcBTaTed0Q/2.jpg' height='97' width='130' time='00:00:18.500'/>
<media:thumbnail url='http://img.youtube.com/vi/zKcBTaTed0Q/1.jpg' height='97' width='130' time='00:00:09.250'/>
<media:thumbnail url='http://img.youtube.com/vi/zKcBTaTed0Q/3.jpg' height='97' width='130' time='00:00:27.750'/>
<media:thumbnail url='http://img.youtube.com/vi/zKcBTaTed0Q/0.jpg' height='240' width='320' time='00:00:18.500'/>
</media:group>
<yt:statistics viewCount='730032' favoriteCount='2122'/><gd:rating min='1' max='5' numRaters='663' average='4.83'/>
<gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/zKcBTaTed0Q/comments' countHint='398'/>
</gd:comments></entry>
And I'm trying to get the values from <published> and <updated> using this XSL file.
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:yt="http://gdata.youtube.com/schemas/2007"
xmlns:gd="http://schemas.google.com/g/2005">
<xsl:template match="/">
<html>
<body>
<h2>Results</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Published</th>
<th align="left">Updated</th>
</tr>
<xsl:for-each select="feed/entry">
<tr>
<td><xsl:value-of select="feed/published" /></td>
<td><xsl:value-of select="feed/updated" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
Does anyone know how to assign the correct namespaces?
Thanks
|