Earlier quoted context omitted.
I still have nightmares from learning XSLT. It's very cool, but also, very strange, if you come from a procedural language background. Also, XSLT is really given power by being mixed with XPath (which is procedural). I suspect that if I had known more about FP back when I learned it, I would have had an easier time. I wrote up a really long, painful post about XSLT, way back in the early 'oughts.
> XPath (which is procedural) XPath is not procedural. It is entirely composed of expressions that compose and return results. The closest common language might be SQL.
Show HN: This website is valid JSON
161–170 of 240 posts
Re: Show HN: This website is valid JSON
#162Re: Show HN: This website is valid JSON
#163Earlier quoted context omitted.
Is the initiator documented anywhere? How come the browser uses it to draw the page?
While the source looks like JSON, the page is still sent by the server as text/html. Browsers are so resilient to malformed markup that actually parse the content inside the tag at the end of the document (firing the JS script that render the actual page), ignoring all the (pseudo) JSON around. The page is rendered in QUIRKSMODE because the source is missing the at the beginning of the document, to resemble valid JSO…
Re: Show HN: This website is valid JSON
#164Re: Show HN: This website is valid JSON
#165Earlier quoted context omitted.
XSLT is mainly used to transform XML into XML. The resulting document doesn’t have to be XML, though. I remember being assigned a task of parsing and importing a large XML document into a MySQL database. This was supposed to be done on PHP. I kind of felt repulsed by the idea of writing the parser in PHP (it would have been horrible). So, I used XSLT to transform the document into CSV and then just imported it using…
Later versions of XSLT added support for more high-level output formats - JSON etc.
2.0 was (maybe still is?) supported by Saxon, a proprietary library, needing to be licensed. Built-in support was capped at 1.5.
If I remember, in order to run XSLT 2.0, you had to license and install Saxon on your server (i believe it was a Java application, meaning the server need to have a JVM), then call it, using system calls. Awkward, at best.
But this was many moons ago. I suspect/hope that things have improved, since then.
Re: Show HN: This website is valid JSON
#166Earlier quoted context omitted.
You are correct. It's a silly hack. Just because it happens to work doesn't make it a good idea. Turn off JavaScript and you just get JSON text.
Here's one that works without JavaScript, you curmudgeon: data:text/html;charset=utf-8,%7B%20%22foo%22%3A%20%22bar%22%2C%20%22baz%22%3A%20%5B%20%22qux%22%20%5D%2C%20%22%23render%22%3A%20%22%3Chtml%3E%3Cbody%3E%3Cdiv%20id%3Dcontent%3E%3Ch1%3EMy%20fancy%20document%3C%2Fh1%3E%3Cp%3EThis%20is%20a%20completely%20%26quot%3Bnormal%26quot%3B%20HTML%20document.%3C%2Fp%3E%3C%2Fdiv%3E%3Cstyle%3Ebody%20%7B%20visibility%3A%20hidd…
Re: Show HN: This website is valid JSON
#167Earlier quoted context omitted.
You are correct. It's a silly hack. Just because it happens to work doesn't make it a good idea. Turn off JavaScript and you just get JSON text.
The page says: > I'm creating a blog platform using this concept. Yeah, please don’t; this is an abomination that’s fun for demonstrating and teaching how these things work, but should absolutely never be used in reality. You could use this as your data model foundation upon which to build a generator , but you should never under any circumstances actually serve this stuff.
Re: Show HN: This website is valid JSON
#168Re: Show HN: This website is valid JSON
#169Earlier quoted context omitted.
XSLT is mainly used to transform XML into XML. The resulting document doesn’t have to be XML, though. I remember being assigned a task of parsing and importing a large XML document into a MySQL database. This was supposed to be done on PHP. I kind of felt repulsed by the idea of writing the parser in PHP (it would have been horrible). So, I used XSLT to transform the document into CSV and then just imported it using…
In the beginning of my career, about 15 years ago, I had a job working with a large auto parts retailer and they had all of their products in these massive XML files. We used XSLT to transform those into all kinds of things, including physical printed catalogues that would go in their stores. Obviously the XSLT didn't actually print catalogues, but we did turn them into some format that I forget now (maybe PDF!) that…