←back to thread

418 points akagusu | 2 comments | | HN request time: 0s | 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 #
ndriscoll ◴[] No.45955537[source]
> JavaScript is better than XSLT in every way

Obviously not in every way. XSLT is declarative and builds pretty naturally off of HTML for someone who doesn't know any programming languages. It gives a very low-effort but fairly high power (especially considering its neglect) on-ramp to templated web pages with no build steps or special server software (e.g. PHP, Ruby) that you need to maintain. It's an extremely natural fit if you want to add new custom HTML elements. You link a template just like you link a CSS file to reuse styles. Obvious.

The equivalent Javascript functionality's documentation[0] starts going on about classes and callbacks and shadow DOM, which is by contrast not at all approachable for someone who just wants to make a web page. Obviously Javascript is necessary if you want to make a web application, but those are incredibly rare, and it's expected that you'll need a programmer if you need to make an application.

Part of the death of the open web is that the companies that control the web's direction don't care about empowering individuals to do simple things in a simple way without their involvement. Since there's no simple, open way to make your own page that people can subscribe to (RSS support having been removed from browsers instead of expanded upon for e.g. a live home page), everyone needs to be on e.g. Facebook.

It's the same with how they make it a pain to just copy your music onto your phone or backup your photos off of it, but instead you can pay them monthly for streaming and cloud storage.

[0] https://developer.mozilla.org/en-US/docs/Web/API/Web_compone...

replies(5): >>45955706 #>>45955862 #>>45955946 #>>45956123 #>>45957628 #
ErroneousBosh ◴[] No.45955946[source]
> not at all approachable for someone who just wants to make a web page

If someone wants to make a web page they need to learn HTML and CSS.

Why would adding a fragile and little-used technology like XSLT help?

replies(2): >>45957790 #>>45958199 #
basscomm ◴[] No.45958199[source]
> Why would adding a fragile and little-used technology like XSLT help?

A few years ago I bought a bunch of Skylanders for practically nothing when the toys to life fad faded away. To keep track of everything I made a quick and dirty XSLT script that sorted and organized the list of figures and formatted each one based on their 'element'. That would have been murderous to do in plain HTML and CSS: https://wyrm.org/inventory/skylanders.xml

replies(1): >>45962060 #
dfabulich ◴[] No.45962060[source]
It would have been murderous with just CSS, but it would have been trivial to do with JS, much easier than the hundreds of lines of XSL you wrote. https://wyrm.org/inventory/skylanders.xsl
replies(1): >>45965154 #
basscomm ◴[] No.45965154[source]
> but it would have been trivial to do with JS

Maybe! How much Javascript would I have to learn before I could come up with a 'trivial' solution?

> the hundreds of lines of XSL you wrote.

Those hundreds of lines are the same copy/pasted if statement with 5 different conditions. For each game, I create a table by: alphabetizing the XML > going through the list searching for figures that match the game > each time I find one go through the color list to find the color to use for the table row. There are 10 color choices per game, which means that I repeated a 10-choice if statement 5 times.

There's nothing difficult here, it's just verbose.

replies(2): >>45969849 #>>45979231 #
1. ErroneousBosh ◴[] No.45979231[source]
> Maybe! How much Javascript would I have to learn before I could come up with a 'trivial' solution?

Less than the amount of XSL you'd need.

> Those hundreds of lines are the same copy/pasted if statement with 5 different conditions.

With a programming language, you could have used loops.

replies(1): >>45979755 #
2. ndriscoll ◴[] No.45979755[source]
What an odd comment to have as a sibling to mine from yesterday showing how to do it with two small templates in xsl (after a minor tweak to the xml):

  <xsl:template match="series">
  <h2><xsl:value-of select="@name"/></h2>
  <table>
    <tr><th>Skylanders figure</th><th>Note</th></tr>
    <xsl:apply-templates select="/skylanders/figure[@series=current()/@id]"><xsl:sort select="name"/></xsl:apply-templates>
  </table>
  </xsl:template>

  <xsl:template match="figure">
  <tr class="element-{ @element }">
    <td><xsl:value-of select="@name" /></td>
    <td><xsl:value-of select="@note" /></td>
  </tr>
  </xsl:template>
No explicit loops necessary.