News for hackers. Stuff that matters.
Re:Chrome intends to remove XSLT from the HTML spec by youngtaff on Tuesday August 19, 2025 @05:41PM (#44956530)
How do you format a raw XML file in the browser without XSLT?
Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Tuesday August 19, 2025 @06:11PM (#44956732)
instead of including a reference to the XSLT sylesheet apparently you can also include javascript: https://stackoverflow.com/a/16426395
Re:Chrome intends to remove XSLT from the HTML spec by youngtaff on Wednesday August 20, 2025 @04:31AM (#44959917)
But can it transform / format the XML?
Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Wednesday August 20, 2025 @08:22AM (#44961244)
why should it not? once loaded it should find the XML in the DOM and transform that any way you like.
Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Saturday August 23, 2025 @01:39PM (#44997649)
for the record, i just tested that the loaded javascript can access the DOM.
Re:Chrome intends to remove XSLT from the HTML spec by LegionMammal978 on Wednesday August 20, 2025 @03:00PM (#44965089)
That's only if the original document is an XHTML document that will have scripts loaded. Other XML documents, such as RSS feeds, will not have any support for JS, short of something silly like putting it in an iframe.
Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Wednesday August 20, 2025 @04:12PM (#44965918)
i didn't test it, but the stackoverflow answers suggested otherwise. are they wrong?
Re:Chrome intends to remove XSLT from the HTML spec by youngtaff on Saturday August 23, 2025 @06:46AM (#44994970)
Perhaps you should have tried testing it before commenting?
Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Saturday August 23, 2025 @01:08PM (#44997386)
if you know that the solution does not work, then just say so and maybe explain why, instead of being snarky.

all i did was to share a link to a resource. if you don't trust that resource you need to do your own testing. what ever i say, whether i tested it or not, doesn't add much more value. you can't trust my words any more than the resource i linked.

you asked half a dozen times in the last few days how a plain xml file can be transformed without xslt. and you claimed that xslt can be used to transform an rss feed.

well, guess what, i just tested this: an rss feed with the standard mimetype application/rss+xml doesn't load either an xsl stylesheet or javascript. to make that work you have to change the mimetype, and if you do that, both the xsl stylesheet or the javascript load. (just not both at the same time)

Re:Chrome intends to remove XSLT from the HTML spec by youngtaff on Saturday August 23, 2025 @04:39PM (#44998956)
At least one of the suggested answers in SO doesn’t work and the other is somewhat painful

Why answer if you don’t know the answer

Here’s one that used application/xml and it works https://www.ellyloel.com/feed.rss

People are using xslt in the wild today and JS isn’t really a replacement

Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Saturday August 23, 2025 @06:06PM (#44999509)
the specific answer that i linked to does work. i have verified that too.

application/xml is not the same as application/rss+xml. application/xml also loads javascript just fine. again, i tested that. so far i have not found a single mimetype that can load xslt, but could not load javascript. i am coming to believe that there isn't one. if xslt works, then javascript works too.

whether javascript itself is a suitable replacement for xslt is not the question. your argument was that it is not possible to replace the builtin xslt support with anything written in javascript, because xml files can't load javascript.

since i have now verified that an xml file that can load xslt in the browser can also load javascript, this is proven wrong. all we need now is a good xslt implementation written in javascript or maybe a good binding to a wasm one and then we are ready to remove the builtin xslt support in the browser.

Re:Chrome intends to remove XSLT from the HTML spec by youngtaff on Sunday August 24, 2025 @04:45AM (#45002544)
I too spent a chunk of time seeing what worked and what it looks like…

JS referenced by the XML can manipulate the XML but it frequently executes before the XML DOM is ready (even when waiting for onload) and so misses elements

So while possible it’s a pretty horrible experience to translate XML to HTML using JS - the declarative approach is more reliable and easier IMV

The XSLT polyfill doesn’t seem to work when loaded as a script in an XML doc but not quite sure why ATM

application/xml is commonly used for RSS feeds on static hosts because it’s the correct mimetype for say a feeds.xml response

Re:Chrome intends to remove XSLT from the HTML spec by 8NNTt8z3QvLT8tp on Monday August 25, 2025 @05:42AM (#45012040)
https://github.com/mfreed7/xslt_polyfill/pull/5 - it will be able to do this soon.
Re:Chrome intends to remove XSLT from the HTML spec by em-bee on Monday August 25, 2025 @08:22PM (#45020810)
nice. thanks for the link.

someone else mentioned xjslt here: https://news.ycombinator.com/item?id=44994310 which is an xslt 2.0 implementation. i have been trying to get that to work by loading the script directly into the xml data but so far could not figure out how to do it.