home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 December
/
PCWorld_2006-12_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-1-2.exe
/
chrome
/
RSSPrettyPrint1.xsl
< prev
next >
Wrap
Extensible Markup Language
|
2006-09-12
|
18KB
|
526 lines
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://purl.org/atom/ns#"
xmlns:atom05="http://www.w3.org/2005/Atom"
xmlns:rss10="http://purl.org/rss/1.0/"
xmlns:rss09="http://my.netscape.com/rdf/simple/0.9/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:nsfeeds="http://www.netscape.com/netscape/feeds/xml"
xmlns="http://purl.org/atom/ns#">
<xsl:output method="xml"/>
<!-- The purpose of this stylesheet is to transform various RSS feed formats
into ATOM('05). -->
<!-- Main body of stylesheet -->
<xsl:template match="/">
<feed>
<xsl:choose>
<xsl:when test="boolean(atom:feed/atom:head)">
<xsl:copy-of select="atom:feed/atom:head"/>
</xsl:when>
<xsl:otherwise>
<head>
<title>
<xsl:choose>
<xsl:when test="boolean(rss/channel/title)">
<xsl:value-of select="rss/channel/title"/>
</xsl:when>
<xsl:when test="boolean(atom:feed/atom:title)">
<xsl:value-of select="atom:feed/atom:title"/>
</xsl:when>
<xsl:when test="boolean(atom05:feed/atom05:title)">
<xsl:value-of select="atom05:feed/atom05:title"/>
</xsl:when>
<xsl:when test="boolean(rdf:RDF/rss10:channel/rss10:title)">
<xsl:value-of select="rdf:RDF/rss10:channel/rss10:title"/>
</xsl:when>
<xsl:when test="boolean(rss10:title)">
<xsl:value-of select="rss10:title"/>
</xsl:when>
<xsl:when test="boolean(rdf:RDF/rss09:channel/rss09:title)">
<xsl:value-of select="rdf:RDF/rss09:channel/rss09:title"/>
</xsl:when>
<xsl:when test="boolean(rdf:RDF/rss09:channel/rss09:description)">
<xsl:value-of select="rdf:RDF/rss09:channel/rss09:description"/>
</xsl:when>
</xsl:choose>
</title>
<updated>Unknown</updated>
<link rel="alternate">
<xsl:attribute name="href">
about:blank
</xsl:attribute>
</link>
</head>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="rssitemlist"/>
<xsl:call-template name="atomitemlist"/>
<xsl:call-template name="atom05itemlist"/>
<xsl:call-template name="rss10itemlist"/>
<xsl:call-template name="rss09itemlist"/>
</feed>
</xsl:template>
<!-- this prints out all of the rss 2.0 articles -->
<xsl:template name="rssitemlist">
<xsl:for-each select="rss/channel/item">
<entry>
<head>
<title><xsl:value-of select='../title'/></title>
<xsl:choose>
<xsl:when test="boolean(../link)">
<link rel="alternate">
<xsl:attribute name="href"><xsl:value-of select="../link"/></xsl:attribute>
</link>
</xsl:when>
</xsl:choose>
<author>Unknown</author>
</head>
<title><xsl:value-of select="title"/></title>
<updated>
<xsl:choose>
<xsl:when test="boolean(pubDate)">
<xsl:value-of select="pubDate"/>
</xsl:when>
<xsl:when test="boolean(dc:date)">
<xsl:value-of select="dc:date"/>
</xsl:when>
</xsl:choose>
</updated>
<nicedate>
<xsl:choose>
<xsl:when test="boolean(pubDate)">
<xsl:value-of select="pubDate"/>
</xsl:when>
<xsl:when test="boolean(dc:date)">
<xsl:value-of select="dc:date"/>
</xsl:when>
</xsl:choose>
</nicedate>
<summary><xsl:value-of select="description"/></summary>
<xsl:if test="boolean(link)">
<link rel="alternate">
<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
</link>
</xsl:if>
</entry>
</xsl:for-each>
</xsl:template>
<!-- this prints out all of the rss 0.9 articles -->
<xsl:template name="rss09itemlist">
<xsl:for-each select="rdf:RDF/rss09:item">
<entry>
<head>
<title>
<xsl:choose>
<xsl:when test="boolean(../rss09:channel/rss09:title)">
<xsl:value-of select='../rss09:channel/rss09:title'/>
</xsl:when>
<xsl:when test="boolean(../rss09:channel/rss09:description)">
<xsl:value-of select='../rss09:channel/rss09:description'/>
</xsl:when>
</xsl:choose>
</title>
<link rel="alternate">
<xsl:choose>
<xsl:when test="boolean(../rss09:channel/rss09:link)">
<xsl:attribute name="href">
<xsl:value-of select="../rss09:channel/rss09:link"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">about:blank</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</link>
<author>Unknown</author>
</head>
<title>
<xsl:choose>
<xsl:when test="boolean(rss09:title)">
<xsl:value-of select='rss09:title'/>
</xsl:when>
<xsl:when test="boolean(rss09:description)">
<xsl:value-of select='rss09:description'/>
</xsl:when>
</xsl:choose>
</title>
<updated>
<xsl:choose>
<xsl:when test="boolean(rss09:pubDate)">
<xsl:value-of select="rss09:pubDate"/>
</xsl:when>
<xsl:when test="boolean(dc:date)">
<xsl:value-of select="dc:date"/>
</xsl:when>
</xsl:choose>
</updated>
<nicedate>
<xsl:choose>
<xsl:when test="boolean(rss09:pubDate)">
<xsl:value-of select="rss09:pubDate"/>
</xsl:when>
<xsl:when test="boolean(dc:date)">
<xsl:value-of select="dc:date"/>
</xsl:when>
</xsl:choose>
</nicedate>
<summary>
<xsl:value-of select="rss09:description"/>
</summary>
<link rel="alternate">
<xsl:attribute name="href"><xsl:value-of select="rss09:link"/></xsl:attribute>
</link>
</entry>
</xsl:for-each>
</xsl:template>
<!-- this prints out all of the atom articles -->
<xsl:template name="atomitemlist">
<xsl:for-each select="atom:feed/atom:entry">
<entry>
<xsl:choose>
<xsl:when test="boolean(atom:head)">
<xsl:copy-of select="atom:head"/>
</xsl:when>
<xsl:when test="boolean(../atom:head)">
<xsl:copy-of select="../atom:head"/>
</xsl:when>
<xsl:otherwise>
<head>
<title><xsl:value-of select="../atom:title"/></title>
<updated>
<xsl:choose>
<xsl:when test="boolean(../atom:updated)">
<xsl:value-of select="../atom:updated"/>
</xsl:when>
<xsl:when test="boolean(../atom:modified)">
<xsl:value-of select="../atom:modified"/>
</xsl:when>
<xsl:when test="boolean(../atom:issued)">
<xsl:value-of select="../atom:issued"/>
</xsl:when>
</xsl:choose>
</updated>
<xsl:copy-of select="../atom:link"/>
<xsl:choose>
<xsl:when test="boolean(../atom:author)">
<xsl:copy-of select="../atom:author"/>
</xsl:when>
<xsl:when test="boolean(atom:author)">
<xsl:copy-of select="atom:author"/>
</xsl:when>
</xsl:choose>
</head>
</xsl:otherwise>
</xsl:choose>
<id><xsl:value-of select="atom:id"/></id>
<summary>
<xsl:choose>
<xsl:when test="boolean(atom:summary)">
<xsl:if test="boolean(atom:summary/@type)">
<xsl:attribute name="type">
<xsl:value-of select="atom:summary/@type"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="boolean(atom:summary/@mode)">
<xsl:attribute name="mode">
<xsl:value-of select="atom:summary/@mode"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="atom:summary"/>
</xsl:when>
<xsl:when test="boolean(atom:description)">
<xsl:if test="boolean(atom:description/@type)">
<xsl:attribute name="type">
<xsl:value-of select="atom:description/@type"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="boolean(atom:description/@mode)">
<xsl:attribute name="mode">
<xsl:value-of select="atom:description/@mode"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="atom:description"/>
</xsl:when>
<xsl:when test="boolean(atom:content)">
<xsl:if test="boolean(atom:content/@type)">
<xsl:attribute name="type">
<xsl:value-of select="atom:content/@type"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="boolean(atom:content/@mode)">
<xsl:attribute name="mode">
<xsl:value-of select="atom:content/@mode"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="atom:content"/>
</xsl:when>
</xsl:choose>
</summary>
<title><xsl:value-of select="atom:title"/></title>
<updated>
<xsl:choose>
<xsl:when test="boolean(atom:updated)">
<xsl:value-of select="atom:updated"/>
</xsl:when>
<xsl:when test="boolean(atom:modified)">
<xsl:value-of select="atom:modified"/>
</xsl:when>
<xsl:when test="boolean(atom:issued)">
<xsl:value-of select="atom:issued"/>
</xsl:when>
<xsl:when test="boolean(../atom:updated)">
<xsl:value-of select="../atom:updated"/>
</xsl:when>
<xsl:when test="boolean(../atom:modified)">
<xsl:value-of select="../atom:modified"/>
</xsl:when>
<xsl:when test="boolean(../atom:issued)">
<xsl:value-of select="../atom:issued"/>
</xsl:when>
</xsl:choose>
</updated>
<nicedate>
<xsl:choose>
<xsl:when test="boolean(atom:updated)">
<xsl:value-of select="atom:updated"/>
</xsl:when>
<xsl:when test="boolean(atom:modified)">
<xsl:value-of select="atom:modified"/>
</xsl:when>
<xsl:when test="boolean(atom:issued)">
<xsl:value-of select="atom:issued"/>
</xsl:when>
<xsl:when test="boolean(../atom:updated)">
<xsl:value-of select="../atom:updated"/>
</xsl:when>
<xsl:when test="boolean(../atom:modified)">
<xsl:value-of select="../atom:modified"/>
</xsl:when>
<xsl:when test="boolean(../atom:issued)">
<xsl:value-of select="../atom:issued"/>
</xsl:when>
</xsl:choose>
</nicedate>
<link rel="alternate">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="boolean(atom:link)">
<xsl:value-of select="atom:link/@href"/>
</xsl:when>
<xsl:when test="boolean(atom:head/atom:link)">
<xsl:value-of select="atom:head/atom:link/@href"/>
</xsl:when>
<xsl:when test="boolean(../atom:link)">
<xsl:value-of select="../atom:link/@href"/>
</xsl:when>
<xsl:when test="boolean(../atom:head/atom:link)">
<xsl:value-of select="../atom:head/atom:link/@href"/>
</xsl:when>
</xsl:choose>
</xsl:attribute>
</link>
</entry>
</xsl:for-each>
</xsl:template>
<!-- this prints out all of the atom05 articles -->
<xsl:template name="atom05itemlist">
<xsl:for-each select="atom05:feed/atom05:entry">
<entry>
<xsl:choose>
<xsl:when test="boolean(atom05:head)">
<xsl:copy-of select="atom05:head"/>
</xsl:when>
<xsl:when test="boolean(../atom05:head)">
<xsl:copy-of select="../atom05:head"/>
</xsl:when>
<xsl:otherwise>
<head>
<title><xsl:value-of select="../atom05:title"/></title>
<updated>
<xsl:choose>
<xsl:when test="boolean(../atom05:updated)">
<xsl:value-of select="../atom05:updated"/>
</xsl:when>
<xsl:when test="boolean(../atom05:modified)">
<xsl:value-of select="../atom05:modified"/>
</xsl:when>
<xsl:when test="boolean(../atom05:issued)">
<xsl:value-of select="../atom05:issued"/>
</xsl:when>
</xsl:choose>
</updated>
<xsl:copy-of select="../atom05:link"/>
<xsl:choose>
<xsl:when test="boolean(../atom05:author)">
<xsl:copy-of select="../atom05:author"/>
</xsl:when>
<xsl:when test="boolean(atom05:author)">
<xsl:copy-of select="atom05:author"/>
</xsl:when>
</xsl:choose>
</head>
</xsl:otherwise>
</xsl:choose>
<id><xsl:value-of select="atom05:id"/></id>
<summary>
<xsl:choose>
<xsl:when test="boolean(atom05:summary)">
<xsl:if test="boolean(atom05:summary/@type)">
<xsl:attribute name="type">
<xsl:value-of select="atom05:summary/@type"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="boolean(atom05:summary/@mode)">
<xsl:attribute name="mode">
<xsl:value-of select="atom05:summary/@mode"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="atom05:summary"/>
</xsl:when>
<xsl:when test="boolean(atom05:description)">
<xsl:if test="boolean(atom05:description/@type)">
<xsl:attribute name="type">
<xsl:value-of select="atom05:description/@type"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="boolean(atom05:description/@mode)">
<xsl:attribute name="mode">
<xsl:value-of select="atom05:description/@mode"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="atom05:description"/>
</xsl:when>
<xsl:when test="boolean(atom05:content)">
<xsl:if test="boolean(atom05:content/@type)">
<xsl:attribute name="type">
<xsl:value-of select="atom05:content/@type"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="boolean(atom05:content/@mode)">
<xsl:attribute name="mode">
<xsl:value-of select="atom05:content/@mode"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="atom05:content"/>
</xsl:when>
</xsl:choose>
</summary>
<title><xsl:value-of select="atom05:title"/></title>
<updated>
<xsl:choose>
<xsl:when test="boolean(atom05:updated)">
<xsl:value-of select="atom05:updated"/>
</xsl:when>
<xsl:when test="boolean(atom05:modified)">
<xsl:value-of select="atom05:modified"/>
</xsl:when>
<xsl:when test="boolean(atom05:issued)">
<xsl:value-of select="atom05:issued"/>
</xsl:when>
<xsl:when test="boolean(../atom05:updated)">
<xsl:value-of select="../atom05:updated"/>
</xsl:when>
<xsl:when test="boolean(../atom05:modified)">
<xsl:value-of select="../atom05:modified"/>
</xsl:when>
<xsl:when test="boolean(../atom05:issued)">
<xsl:value-of select="../atom05:issued"/>
</xsl:when>
</xsl:choose>
</updated>
<nicedate>
<xsl:choose>
<xsl:when test="boolean(atom05:updated)">
<xsl:value-of select="atom05:updated"/>
</xsl:when>
<xsl:when test="boolean(atom05:modified)">
<xsl:value-of select="atom05:modified"/>
</xsl:when>
<xsl:when test="boolean(atom05:issued)">
<xsl:value-of select="atom05:issued"/>
</xsl:when>
<xsl:when test="boolean(../atom05:updated)">
<xsl:value-of select="../atom05:updated"/>
</xsl:when>
<xsl:when test="boolean(../atom05:modified)">
<xsl:value-of select="../atom05:modified"/>
</xsl:when>
<xsl:when test="boolean(../atom05:issued)">
<xsl:value-of select="../atom05:issued"/>
</xsl:when>
</xsl:choose>
</nicedate>
<link rel="alternate">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="boolean(atom05:link)">
<xsl:value-of select="atom05:link/@href"/>
</xsl:when>
<xsl:when test="boolean(atom05:head/atom05:link)">
<xsl:value-of select="atom05:head/atom05:link/@href"/>
</xsl:when>
<xsl:when test="boolean(../atom05:link)">
<xsl:value-of select="../atom05:link/@href"/>
</xsl:when>
<xsl:when test="boolean(../atom05:head/atom05:link)">
<xsl:value-of select="../atom05:head/atom05:link/@href"/>
</xsl:when>
</xsl:choose>
</xsl:attribute>
</link>
</entry>
</xsl:for-each>
</xsl:template>
<!-- this prints out all of the rss 1.0 articles -->
<xsl:template name="rss10itemlist">
<xsl:for-each select="rdf:RDF/rss10:channel">
<xsl:call-template name="rss10item"/>
</xsl:for-each>
</xsl:template>
<xsl:template name="rss10item">
<xsl:variable name="title" select="rss10:title"/>
<xsl:for-each select="../rss10:item">
<entry>
<head>
<title><xsl:value-of select='$title'/></title>
<link rel="alternate">about:blank</link>
<author>Unknown</author>
</head>
<title><xsl:value-of select="rss10:title"/></title>
<updated><xsl:value-of select="dc:date"/></updated>
<nicedate><xsl:value-of select="dc:date"/></nicedate>
<summary>
<xsl:choose>
<xsl:when test="boolean(rss10:description)">
<xsl:value-of select="rss10:description"/>
</xsl:when>
<xsl:when test="boolean(content:encoded)">
<xsl:attribute name="type">html</xsl:attribute>
<xsl:value-of select="content:encoded"/>
</xsl:when>
</xsl:choose>
</summary>
<link rel="alternate">
<xsl:attribute name="href"><xsl:value-of select="rss10:link"/></xsl:attribute>
</link>
</entry>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>