Skip to content

Comment on Intent to Unship: XSLT

Comments

Now seems a good time to mention that you can beautify your XML RSS/Atom feeds without XSLT using CSS and JS.

You can add a stylesheet to an Atom feed by adding a <link> tag with an xmlns attribute, like this:

    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <link rel="stylesheet" href="style.css" xmlns="http://www.w3.org/1999/xhtml" />
        <!-- ... the rest of the feed goes here ... -->
Or add styles directly with a <style> tag:
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <style xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
            * { color: red; }
        ]]></style>
        <!-- ... the rest of the feed goes here ... -->
You can even run JavaScript when users browse to your feed like this:
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
        <script src="script.js" xmlns="http://www.w3.org/1999/xhtml" />
        <!-- ... the rest of the feed goes here ... -->
You can use JS to transform your XML, just like you can (could) with XSLT.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.