←back to thread

116 points vgr-land | 7 comments | | HN request time: 1.358s | source | bottom

A few weeks ago a friend sent me grug-brain XSLT (1) which inspired me to redo my personal blog in XSLT.

Rather than just build my own blog on it, I wrote it up for others to use and I've published it on GitHub https://github.com/vgr-land/vgr-xslt-blog-framework (2)

Since others have XSLT on the mind, now seems just as good of a time as any to share it with the world. Evidlo@ did a fine job explaining the "how" xslt works (3)

The short version on how to publish using this framework is:

1. Create a new post in HTML wrapped in the XML headers and footers the framework expects.

2. Tag the post so that its unique and the framework can find it on build

3. Add the post to the posts.xml file

And that's it. No build system to update menus, no RSS file to update (posts.xml is the rss file). As a reusable framework, there are likely bugs lurking in CSS, but otherwise I'm finding it perfectly usable for my needs.

Finally, it'd be a shame if XSLT is removed from the HTML spec (4), I've found it quite eloquent in its simplicity.

(1) https://news.ycombinator.com/item?id=44393817

(2) https://github.com/vgr-land/vgr-xslt-blog-framework

(3) https://news.ycombinator.com/item?id=44988271

(4) https://news.ycombinator.com/item?id=44952185

(Aside - First time caller long time listener to hn, thanks!)

Show context
dehrmann ◴[] No.45009536[source]
Haven't seen this much interest in XML/XSLT in 20 years.
replies(1): >>45011490 #
1. wiz21c ◴[] No.45011490[source]
Fortunately! It was cool to do the easy things, but then you had monstruous path expressions, and all sort of programmatical drama.. Pfff...

did you know that XSLT was shown to be Turing complete ? https://staff.emu.edu.tr/zekibayram/Documents/papers/XSLT_Tu...

On the other side, I find XML/XSD still much better than JSON. JSON is way too simple...

replies(1): >>45012792 #
2. whizzter ◴[] No.45012792[source]
Depends on the task, JSON won because it was so simple whilst XML is waaay to complex. Maybe an alternative to JSON with just a tad more complexity for sanity could have won 20 years ago, but alas it never happened.
replies(1): >>45012843 #
3. _heimdall ◴[] No.45012843[source]
JSON is less complex because it only solves some of the problems that XML solves. That doesn't make it better or worse, but adding schema support or attempting to make REST APIs with JSON because complex, and IMO fragile, quickly.
replies(2): >>45019480 #>>45022792 #
4. IshKebab ◴[] No.45019480{3}[source]
It solves the important problems that XML solved, without the mistakes.

What is it missing? I think only namespacing, but that isn't really necessary in JSON because it isn't a document format where arbitrary elements can appear in arbitrary places. I have never once needed namespacing in JSON.

Schemas... well there's JSON schema which is ok I guess. But in reality you probably don't want that either. Schemas are useful for IDEs and linters but that's it. Normally you validate a JSON file by parsing it, e.g. with Pydantic or Serde or Zod.

The biggest missing feature from XML that JSON should have had is comments! Yes it was a mistake to omit them.

replies(1): >>45021705 #
5. _heimdall ◴[] No.45021705{4}[source]
Validating JSON with third party runtime libraries like zod is only necessary because JSON doesn't support schemas though. There's nothing wrong with those libraries, they solve a real problem but the problem is in JSON itself.

The whole point of REST was to allow visitors to not only see the response to a request but to also be able to understand both the semantics and the functionality of it.

Think HTML - it would be comparatively useless if HTML could only contain structured data with meaning, semantics, or schemas. Anchor tags, buttons, and forms are semantic and tell the user not only what a piece of text is but how they can interact with it.

With JSON you have to know the shape of requests supported, the shape of data returned, and how to use that data to make other requests.

replies(1): >>45023015 #
6. whizzter ◴[] No.45022792{3}[source]
On the contrary I think they did the right thing in not supporting any schema it.

1: The "simpleness" made it easy for producers/consumers with unstructured languages (ie JS,Python,PHP,Ruby,etc) to participate in the ecosystem without feeling that things were "bloated" (technically a drawback perhaps but pushed popularity)

2: DTD was put into the standard, but from my recollection most stuff was defined with XSD in practice (so a separate standard), so now implementations needed to carry both deprecated stuff and another layer. (Then again, sure you could generate bindings with XSD).

3: We needed 3 versions of Swagger/OpenAPI to come to a somewhat good standardized binding API (it itself depends/extends JSON Schema), but it's there today and we don't need to consider deprecated libraries,etc and can just point our code-generators to the schema documents and get automatic bindings.

So in practice you basically have no fragility today even if there is binding generator bugs, but that feels more of an implementation issue than a systematic error, and if anything it shows that schema generators.

Now one could argue that the "free-ness" of the JSON Format made schema generators needlessly cumbersome, and maybe that's true to a certain extent but it's still not nearly as bad as trying to interpret ASN.1 files despite all the standards (there it is.. "good luck trying to find the correct IDL files").

7. IshKebab ◴[] No.45023015{5}[source]
> Validating JSON with third party runtime libraries like zod is only necessary because JSON doesn't support schemas though.

No this is completely backwards. First of all, JSON Schema exists. Second libraries like Serde and Pydantic aren't schema validators; they are parsers. They parse strings (or sometimes dynamically typed JSON) into statically typed objects that you can actually use in your program. That's what you should use.

A program that uses a separate schema validator and then blindly trusts the result is badly designed. There's even a name for this mistake - "parse don't validate" (you can Google it).

> With JSON you have to know the shape of requests supported, the shape of data returned, and how to use that data to make other requests.

Obviously. XML doesn't magically avoid the need for API documentation! I'm wondering if you've ever actually used XML at this point....