Hacker News new | ask | show | jobs
by adulau 5692 days ago
My biggest issue with XML is "XML misunderstands Unix philosophy". You can't easily use cut, awk and grep with XML without having a million of edge case to handle. There are some tools like XMLStarlet, xsltproc or xalan. But you can't safely extract content from XML files with standards tools even if you use the XML extension for gawk.

You could argue that XML documents are complex and cannot be described using simple comma separated. Maybe but some many XML documents are just there to store simple key,value data.

And now, we have "jsawk" (https://github.com/micha/jsawk) for parsing JSON under your terminal...

2 comments

Actually, the problem is XML demonstrates the limits of the "UNIX philosophy". Plain text simply isn't the be-all, end-all of formats. You can't easily use cut, awk, or grep on JSON, either. The "UNIX philosophy" does poorly with trees and graphs (in the computer science sense).

That's not a bad thing. The UNIX philosophy encourages you to avoid those things if you don't need them. It's very powerful. But when you actually, factually need them, you're not going to get very far with UNIX tools. That's OK; it is neither an indictment of UNIX nor of the data. Different tools are called for.

xsl and transforms are what you use to extract data from xml. xslt is the coolest thing about xml IMHO.

the only real complaint I have is that xsl, being itself xml, is pretty verbose and can be tedious to write.

xslt is beyond tedious, it is infuriating. There are few use cases for xslt that would not be better served with a procedural technique, eg. python and a parser.

also the whole "using xml to define a transformation on some other xml" thing is so overly meta as to induce a massive brain hemorrhage out of my nose and all over my desk.

Fortunately you can now use XPath for simple queries and XQuery beyond that.
Forgot about them. Both XPath and XQuery are excellent technologies and a probably the best thing about XML in my experience with it. I highly recommend everyone concerned with XML check them out if they havent already. I never seem to see much mention of them around XML discussions.

http://www.w3schools.com/xquery/xquery_intro.asp

> I never seem to see much mention of them around XML discussions.

Which is a shame since I've been banging my head against a particular set of problems for a while with XML, and XQuery nicely resolves that, and I think it's easier to use than SQL for the most part.

Ironically probably the most popular application of XPath in the real world is jQuery selectors! Although I don't know whether that weakens or strengthens the case for JSON...