Example of transforming rss 2.0 with xsl to html

The RSS feed. I'm using the IU itnotices feed: http://itnotices.iu.edu/rss.aspx »

rss.xml

Note: There are custom tags not in the RSS 2.0 specifications in this RSS feed. Just ignore them. :)

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
        <channel>
                <title>
                        IT Notices - Current Notices
                </title>
                <link>
                        http://itnotices.iu.edu/
                </link>
                <description>
                        Notices about Information Technology services at Indiana University
                </description>
                <copyright>
                        Copyright 2009, The Trustees of Indiana University
                </copyright>
                <ttl>
                        5
                </ttl>
                <image>
                        <title>
                                IT Notices - Current Notices
                        </title>

                        <url>
                                http://itnotices.iu.edu/images/uits.png
                        </url>
                        <link>
                                http://itnotices.iu.edu/
                        </link>
                </image>
                <item>
                        <link>
                                http://itnotices.iu.edu/notice.aspx?id=13180
                        </link>
                        <guid>
                                http://itnotices.iu.edu/notice.aspx?id=13180
                        </guid>
                        <title>
                                Oncourse Fall 2009 course availability for students
                        </title>
                        <message>
                                On Monday, August 3, Fall 2009 courses will become available to students in Oncourse.
                        </message>
                        <lastUpdated>
                                Mon 7/27/2009 2:20 PM EDT
                        </lastUpdated>
                        <pubDate>
                                Mon 7/27/2009 2:15 PM EDT
                        </pubDate>
                        <noticeOpen>
                                Mon 7/27/2009 2:15 PM EDT
                        </noticeOpen>
                        <noticeClose>
                                Mon 8/31/2009 8:00 AM EDT
                        </noticeClose>
                        <noticeType>
                                Announcement
                        </noticeType>
                        <service>
                                Oncourse
                        </service>
                        <description>
                                &lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='http://itnotices.iu.edu/images/announce_large.png'/&gt;&lt;/td&gt;&lt;td&gt;Oncourse&lt;br/&gt;Announcement&lt;br/&gt;Last updated: Mon 7/27/2009 2:20 PM EDT&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
                        </description>
                </item>
                <item>
                        <link>
                                http://itnotices.iu.edu/notice.aspx?id=13155
                        </link>
                        <guid>
                                http://itnotices.iu.edu/notice.aspx?id=13155
                        </guid>
                        <title>
                                Cyrus account migration
                        </title>
                        <message>
                                Beginning Wednesday, July 22, existing faculty, staff, and departmental Cyrus accounts will be migrated to new servers. Migrations will take place between 6:00pm and 7:00am Monday through Friday and will continue throughout the day Saturday and Sunday.

                                &lt;p&gt;
                                Users whose accounts are designated to be moved will receive direct email notification before and after the migration. Individual account migrations may take up to 90 minutes. During this time, account contents will be read-only and incoming mail will be held for later delivery. Administrators advise that users should not attempt to compose or send messages while their account is being migrated.
                                &lt;/p&gt;
                        </message>
                        <lastUpdated>
                                Fri 7/17/2009 5:07 PM EDT
                        </lastUpdated>
                        <pubDate>
                                Fri 7/17/2009 12:00 AM EDT
                        </pubDate>
                        <noticeOpen>
                                Fri 7/17/2009 12:00 AM EDT
                        </noticeOpen>
                        <noticeClose>
                                Mon 8/24/2009 11:59 PM EDT
                        </noticeClose>
                        <noticeType>
                                Announcement
                        </noticeType>
                        <service>
                                Cyrus
                        </service>
                        <description>
                                &lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='http://itnotices.iu.edu/images/announce_large.png'/&gt;&lt;/td&gt;&lt;td&gt;Cyrus&lt;br/&gt;Announcement&lt;br/&gt;Last updated: Fri 7/17/2009 5:07 PM EDT&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
                        </description>
                </item>
                <item>
                        <link>
                                http://itnotices.iu.edu/notice.aspx?id=12848
                        </link>
                        <guid>
                                http://itnotices.iu.edu/notice.aspx?id=12848
                        </guid>
                        <title>
                                PPTP VPN retirement
                        </title>
                        <message>
                                On Monday, July 13, 2009 the PPTP VPN (Point-to-Point Tunneling Protocol for virtual private network) service will be retired at IUB (Bloomington) and IUPUI (Indianapolis).

                                &lt;p&gt;
                                Access to IPSec (Internet Protocol Security) VPN and SSL (Secure Socket Layer) VPN will remain available.&lt;/p&gt;
                                &lt;p&gt;
                                For additional information about the SSL VPN Project  see:&lt;br&gt;

                                &lt;a href="http://uits.iu.edu/page/ayfp"&gt;http://uits.iu.edu/page/ayfp.html&lt;/a&gt;&lt;/p&gt;
                                &lt;p&gt;

                                For additional information about IPSec see:&lt;br&gt;
                                &lt;a href="https://kb.iu.edu/data/aodq.html"&gt;https://kb.iu.edu/data/aodq.html&lt;/a&gt;&lt;/p&gt;

                                &lt;p&gt;
                                For additional information about VPN see:&lt;br&gt;
                                &lt;a href="https://kb.iu.edu/data/ajrq.html"&gt;https://kb.iu.edu/data/ajrq.html&lt;/a&gt;&lt;/p&gt;
                        </message>
                        <lastUpdated>
                                Thu 5/28/2009 12:19 PM EDT
                        </lastUpdated>
                        <pubDate>
                                Fri 4/17/2009 10:00 AM EDT
                        </pubDate>
                        <noticeOpen>
                                Fri 4/17/2009 10:00 AM EDT
                        </noticeOpen>
                        <noticeClose>
                                Fri 7/31/2009 5:00 PM EDT
                        </noticeClose>
                        <noticeType>
                                Announcement
                        </noticeType>
                        <service>
                                IUB VPN
                        </service>
                        <service>
                                IUPUI VPN
                        </service>
                        <description>
                                &lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='http://itnotices.iu.edu/images/announce_large.png'/&gt;&lt;/td&gt;&lt;td&gt;IUB VPN, IUPUI VPN&lt;br/&gt;Announcement&lt;br/&gt;Last updated: Thu 5/28/2009 12:19 PM EDT&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
                        </description>
                </item>
        </channel>
</rss>

rss.xsl

<xsl:stylesheet version = "1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="html" encoding="ASCII" omit-xml-declaration="yes" />
        <xsl:template match="/rss/channel">
                <ul>
                        <xsl:for-each select="//item">
                                <li>
                                        <xsl:element name="a">
                                                <xsl:attribute name="href">
                                                        <xsl:value-of select="./link" />

                                                </xsl:attribute>
                                                <xsl:value-of select="./title" />
                                        </xsl:element>
                                </li>
                        </xsl:for-each>
                </ul>
        </xsl:template>
</xsl:stylesheet>

rss.html

If you are using unix and have xsltproc installed, you can test your xsl stylesheet with the following command,

$ xsltproc -o rss.html rss.xsl rss.xml
<ul>
        <li>
                <a href="http://itnotices.iu.edu/notice.aspx?id=13180%0A%09%09%09">
                        Oncourse Fall 2009 course availability for students
                </a>
        </li>
        <li>
                <a href="http://itnotices.iu.edu/notice.aspx?id=13155%0A%09%09%09">
                        Cyrus account migration
                </a>
        </li>
        <li>
                <a href="http://itnotices.iu.edu/notice.aspx?id=12848%0A%09%09%09">
                        PPTP VPN retirement
                </a>
        </li>
</ul>

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.