←back to thread

418 points akagusu | 3 comments | | HN request time: 0.001s | source
Show context
dfabulich ◴[] No.45955306[source]
In part 1 of this article, the author wrote, "XSLT is an essential companion to RSS, as it allows the feed itself to be perused in the browser"

Actually, you can make an RSS feed user-browsable by using JavaScript instead. You can even run XSLT in JavaScript, which is what Google's polyfill does.

I've written thousands of lines of XSLT. JavaScript is better than XSLT in every way, which is why JavaScript has thrived and XSLT has dwindled.

This is why XSLT has got to go: https://www.offensivecon.org/speakers/2025/ivan-fratric.html

replies(7): >>45955537 #>>45955587 #>>45955938 #>>45955985 #>>45956639 #>>45956745 #>>45958606 #
kuschku ◴[] No.45956639[source]
> Actually, you can make an RSS feed user-browsable by using JavaScript instead

Say I have an XML document that uses XSLT, how do I modify it to apply your suggestion?

I've previously suggested the XML stylesheet tag should allow

    <?xml-stylesheet type="application/javascript" href="https://example.org/script.js"?>
which would then allow the script to use the service-worker APIs to intercept and transform the request.

But with the implementation available today, I see no way to provide a first-class XSLT-like experience with JS.

replies(1): >>45959824 #
1. dfabulich ◴[] No.45959824[source]
For RSS/Atom, you put this in the XML, right inside the document element (the <feed> element or the <rss> element):

    <script src="https://example.org/script.js"
       xmlns="http://www.w3.org/1999/xhtml"></script>
You can also put CSS in there, like this:

    <style xmlns="http://www.w3.org/1999/xhtml">
      * { color: red; }
    </style>
Or like this:

    <link href="https://example.org/style.css"
       rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml"/>
replies(1): >>45960149 #
2. kuschku ◴[] No.45960149[source]
How's the support for the first option? If that reliably works, I'm gonna stop being angry, as it solved all my needs (and would allow polyfilling xslt anyway)

On second thought, that wouldn't allow me to modify the DOM before it's being parsed, I'd have to wipe the DOM and polyfill the entire page load, right?

replies(1): >>45962117 #
3. dfabulich ◴[] No.45962117[source]
It works great in Chrome, Safari, and Firefox.

https://github.com/dfabulich/style-xml-feeds-without-xslt

Google has recommended a polyfill for XSLT ever since they announced their plan to remove it. https://developer.chrome.com/docs/web-platform/deprecating-x...