I Love XML. Well-designed XML is better than well-designed JSON IMHO for human readability.
However, I can live with its successor Lord JSON. But the ArchDemon YAML - my lord in heaven - who summoned that monster ? I get strong urges to quit software and go into a cave crying after any time dealing with it.
The XML ecosystem is truly staggering. I can't say if any of it is "because" of XML, or simply XML was the thing these different projects hitched their wagons too, just because of ubiquity and momentum.
It is imperfect, but still extraordinary.
One of my favorites is XSL/XLT. Yes it's a programming language in XML that's apt at working with XML. But that's the thing, you have an XML programming language that can easily manipulate XML. What other language does that remind folks of? It's also functional. Hard to hear yourself think around XSL because of all the buzzwords flying around.
An early idea, which never caught on, but was still clever, was download XSL files to the client, and then simply serving up XML files to be rendered by the local XSL. We actually did this with CDAs in healthcare (CDAs are essentially XML health care records). That was a driving thing with CDAs. There were actually contests for student groups to come up with stylings of CDAs.
The idea of stylesheets and XML is really powerful. HTML and CSS are joined at the hip, but that's happenstance. CSS can be applied to raw XML, but that aspect of it never matured like HTML and CSS did.
Then you have things like XSL-FO, giving a straight pipeline from raw XML to a formatted output.
I love XML namespaces. The idea of "hiding" meta data into XML files is quite cool. It was straight forward to consider XML elements in other name spaces as no more interesting than comments. This was used to great effect in SOAP and web services. A nice use case was bundling XML-Sig payloads. This was used in SOAP, in SAML. That was the beauty of it. In theory, you could plonk it most anywhere.
Yes, it had its problems regarding normalization and such. And, yes, XML is complicated. There were certainly some sharp corners in dark rooms to bang you head on with XML. It suffered interoperability issues, but then everything did. Everything still does. That's not XMLs fault, that's just humanity.
It's a powerful lingua franca. Once you get something into an XML format, there's so much that can be done with it, stuff we've been doing for 20 years. JSON et al are still trying to catch up, and suffering similar problems that XML has suffered through.
The S-expression is trivially parseable; the XML, OTOH, requires a fairly complex (hence potentially buggy and insecure) piece of software — and if you’re not careful, you’re susceptible to a billion-laughs attack. The XML will be littered with extraneous text elements between the tags; the S-expression is not. The S-expression just has atoms and lists; the XML has both tags and attributes. Why is publisher an attribute while title is a tag? Who knows?
It’s probably not a coincidence that a Google search for "well-designed XML" yields very few results, with your comment one of those few.
Sorry not a good example by deliberately bloating the XML and also adding double-line spacing. title, author and publication-date should be XML attributes as they don't have children and are singular data of a singular data type.
<books xmlns='http://www.example.com/books'>
<book author="Frederick Brooks"
publication-date="1995-06-30"
title="Mythical Man Month" />
<book author="Eric Gunnerson"
publication-date="2001-06-30"
title="Programmer’s Introduction to C#" />
</books>
Sweet, succinct, elegant and can be validated with an XSD and given auto-complete and tab placeholder support in your editor/IDE.
The above can be parsed without bugginess or insecurity - those feel like opinions to me. We manage to parse and render trillions of HTML markup following the same style without issues.
I just pulled the example from the article ‘Designing Extensible, Versionable XML Formats’ hosted at xml.com. Presumably xml.com has decent examples of XML?
I an pretty sure that author is not a singular data type, since it is possible for a book to have multiple authors.
> Sweet, succinct, elegant
I think it’s still inelegant in comparison to the S-expression version.
> The above can be parsed without bugginess or insecurity - those feel like opinions to me.
Could you share some examples? Genuinely interested as I really only know those god awful and huge Maven configs as things one would mostly edit by hand
Maven is an excellent example where the original author forgot that XML attributes exist. Or rather he chose to use a use a terrible parser than didn't support them. And overly verbose names.
With a nice XSD, the below could be typed with full autocomplete and tab-next-placeholder support for element and attribute names in both neovim/vscode/ intellij.
<proj name="My Biz CLI" url="http://github.com/mybiz/mybizctl" modelVersion="4.0.0">
<coord groupId="com.mybiz" artifactId="mybizctl" version="1.0.0" packaging="jar" />
OR
<coord>com.mybiz:mybizctl:jar:1.0.0</coord> <!-- alt form -->
<deps>
<dep groupId="junit" artifactId="junit" version="5.0.1" scope="test" />
<dep>info.picocli:picocli:4.7.1</dep> <!-- alt form -->
</deps>
</proj>
The above declares a project CLI tool with proj metadata and a defined coordinate producing a jar file with 1 compile time dependency and 1 test dependency.
I probably should have omitted alternatives and comments in my example - would have come to the same length then and just as easy to read. Did so below and even more pleasant to read - esp for folks already used to HTML.
Maven is not a great example of the strengths of XML, as another comment describes.
I use XML a lot in favor of JSON because I can pass around a machine readable schema (yes, I know JSON now has some schema support) and because I can represent things like cycles and comments and numbers that are something other than 64-bit floating point values.
However, I can live with its successor Lord JSON. But the ArchDemon YAML - my lord in heaven - who summoned that monster ? I get strong urges to quit software and go into a cave crying after any time dealing with it.