XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old March 18th, 2008, 02:21 PM
Hysteria86 Hysteria86 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 111 Hysteria86 User rank is Lance Corporal (50 - 100 Reputation Level)Hysteria86 User rank is Lance Corporal (50 - 100 Reputation Level)Hysteria86 User rank is Lance Corporal (50 - 100 Reputation Level) 
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

Reply With Quote
  #2  
Old March 19th, 2008, 01:30 PM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 474 jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 18 m 31 sec
Reputation Power: 52
Unfortunately, xsl treats all elements as being in the default namespace unless specified, not the one specified by xmlns

Code:

<xsl:stylesheet version="1.0" xmlns:a='http://www.w3.org/2005/Atom'  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
....


<xsl:for-each select="a:feed/a:entry">
  <tr>
    <td><xsl:value-of select="a:published" /></td>
    <td><xsl:value-of select="a:updated" /></td>
...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL Namespaces


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway