XSL Not returning any data when applied to a XML



I have an XML which looks like this



<feed xmlns="http://ift.tt/r5ut6F">
<script id="tinyhippos-injected"/>
<title>sponsor_bluemoon General on Huffington Post</title>
<link href="http://ift.tt/1xphDqP" rel="self" type="application/rss+xml"/>
<link rel="alternate" type="text/html" href="http://ift.tt/1xphDHk"/>
<logo>
http://ift.tt/PuyNCQ
</logo>
<id>
tag:http://ift.tt/1uzrTAP
</id>
<updated>2014-07-24T08:03:25Z</updated>
<generator uri="http://ift.tt/hFWySe">Huffington Post</generator>
<entry>
<title>
The Second Half Of The MLB Season Is Going To Be Intense
</title>
<link rel="alternate" type="text/html" href="http://ift.tt/1rxscZ6"/>
<id>
http://ift.tt/1rxscZ6
</id>
<published>2014-07-24T08:03:25Z</published>
<updated>2014-07-24T08:03:28Z</updated>
<author>
<name>The Huffington Post News Team</name>
<uri>http://ift.tt/1xphEej;
</author>
<content type="html" xml:lang="en-US" xml:base="http://ift.tt/hFWySe">
It's going to be a fun, and very intense, second half of the baseball season. <br /> <br /> By the All-Star break, one division in the National League had a tie... <p>Read more: <a href="/tag/brew-pub">Brew-Pub</a>, <a href="/tag/baseball">Baseball</a>, <a href="/tag/mlb">Mlb</a>, <a href="/tag/major-league-baseball">Major League Baseball</a>, <a href="/tag/mlb-division-races">Mlb Division Races</a>, <a href="/sports">Sports News</a></p>
</content>
<link href="http://ift.tt/1uzrRsG" type="image/jpeg" rel="enclosure"/>
</entry>


The nodes are repeated and hence I am "for each"ing those entry node to extract title author id link and content. Right now I have written xsl to extract only the author and title. But my xsl doesn't return anything. My XSL Looks like this



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0"
xmlns:media="http://ift.tt/W3lYmr">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<rss xmlns:georss="http://ift.tt/N7lROd" xmlns:twitter="http://api.twitter.com" xmlns:atom="http://ift.tt/r5ut6F" version="2.0">
<channel>
<author>
<xsl:text>Content-Feed-Pics</xsl:text>
</author>
<xsl:for-each select="xml//entry[position() &lt; 10]">
<item>
<title><xsl:value-of select="title"/></title>
<author><xsl:value-of select="author/name"/></author>
<!-- <icon>
<xsl:value-of select="concat(entities/media//media_url,':thumb')"/>
</icon>-->


<!--link><xsl:value-of select="entities/media//media_url"/></link-->
<!--description><xsl:value-of select="text"/></description>
<pubDate><xsl:value-of select="created_at"/></pubDate-->
<!-- <xsl:apply-templates select="entities/media//media_url"/>-->
</item>
</xsl:for-each>
</channel>
</rss>
</xsl:template>

<!--xsl:template match="entities/media//media_url"-->
<!-- <enclosure>
<xsl:attribute name="url">
<xsl:value-of select="concat(., ':thumb')" />
</xsl:attribute>
<xsl:attribute name="type">
<xsl:text>image/jpg</xsl:text>
</xsl:attribute>
</enclosure>-->
<!--/xsl:template-->
</xsl:stylesheet>



Please let me know where I am going wrong. Before using xml//entry I used feed/entry and //entry but that didn't works as well. Please advice.


No comments:

Post a Comment