News for hackers. Stuff that matters.
Re:The Goals of XML at 25: and the one change that XML now n... by ram_rar on Sunday July 18, 2021 @04:55PM (#27876592)
Its too little too late. XML tried to do too many things. The web always loves things that are quick and dirty. JSON with all its shortcomings was simple enough to get going. Couple it with HTTP, you can easily get a web service up and running.

I wonder, for what are the use cases today one would prefer XML over JSON/GRPC/GraphQL etc ?

Re:The Goals of XML at 25: and the one change that XML now n... by tannhaeuser on Sunday July 18, 2021 @05:09PM (#27876699)
XML was introduced as a simplified SGML subset to base new versions of HTML (XHTML) and other web vocabularies (SVG, MathML) on, but that failed and HTML5 still continues to use tag inference, shortforms, and other SGML features that didn't make it into XML. It wasn't conceived as a payload format for web services.
Re:The Goals of XML at 25: and the one change that XML now n... by Ygg2 on Monday July 19, 2021 @05:39AM (#27880699)
There was a desire to do similar for XML. See XML5 than Anne van Kestren worked on.

https://annevankesteren.nl/2007/10/xml5

I wrote a parser for it, but it never got traction.

I might have to rewrite it again.

Re:The Goals of XML at 25: and the one change that XML now n... by skissane on Monday July 19, 2021 @07:11AM (#27881247)
Personally I prefer Tim Bray's XML-SW to Anne van Kestren's XML5:

http://www.textuality.com/xml/xmlSW.html

XML-SW drops the internal DTD subset entirely, including entity declarations; this means it doesn't support named entity references except for the predefined ones (apos, quot, gt, lt, amp). I think DTDs are one of the ugliest things in XML (and also a well-known source of security vulnerabilities), and it is great that XML-SW (unlike XML5) mostly kills them.

I'm also not sold on the whole "HTML-style error-recovery" idea in XML5. In my mind, the syntactic strictness of XML is a virtue not a vice.

I'd support killing processing instructions as well. They are rarely used, and XML namespaces could be used as a replacement.

Re:The Goals of XML at 25: and the one change that XML now n... by tannhaeuser on Monday July 19, 2021 @09:21AM (#27882351)
> DTDs are one of the ugliest thing ... not sold on the whole "HTML-style error-recovery"

I think there might be a misconception here. HTML5 does have some ad-hoc rules around script, style, and noscript elements, but the vast majority of tag inference it does is straight from SGML, from which both HTML and XML are derived. Tag inference in SGML is driven by (parent) element content models and per-element tag omission indicators. For example, a minimal HTML doc can look as simple as

    <title>XYZ</title>
    <p>body text
and SGML and HTML infer omitted tags to arrive at

    <html>
      <head>
        <title>XYZ</title>
      </head>
      <body>
        <p>body text</p>
      </body>
    </html>
The concept of hierarchically structuring a partially tagged text document, possibly with custom Wiki syntax a la markdown, is pretty fundamental to SGML-style angle-bracket markup, and also required to unambiguously assign an address (path) to every node such that it can be styled using eg CSS. Since it requires declarations or a hard-coded vocabulary, it'd be difficult to remove DTDs/element declarations.

SGML is formalized in ISO 8879:1986, and there's absolutely nothing vague or speculative about the kind of tag inference it does. It's just that most people don't seem to know SGML and come up with ad-hoc XML extensions that can't be taken seriously without reference and alignment within the greater SGML context when XML itself is specified as a proper SGML subset.

It's interesting that you'd be willing to trade processing instructions for XML namespaces. Most experts, including the article's author, seem to agree that namespaces and XML Schema are the worst XML offenders, taking the just gained simplicity of XML away on the spot.

Re:The Goals of XML at 25: and the one change that XML now n... by johncowan on Tuesday July 20, 2021 @12:34PM (#27895940)
You might want to look at MicroXML <https://dvcs.w3.org/hg/microxml/raw-file/tip/spec/microxml.h...> then. No XML declaration, no DTDs, no PIs, no CDATA sections, no cruft.
Re:The Goals of XML at 25: and the one change that XML now n... by Ygg2 on Monday July 19, 2021 @08:30AM (#27881887)
> I'm also not sold on the whole "HTML-style error-recovery"

Having used and written a parser for a similar recoverable localization language (https://projectfluent.org/) I'm sold on it.

It makes a lot of things easier. It's kinda like adding trailing comma to lists. It's both boon when writing lists by hand and generating it via code.

> I think DTDs are one of the ugliest things in XML (and also a well-known source of security vulnerabilities), and it is great that XML-SW (unlike XML5) mostly kills them.

Hm, that's strange. I'm pretty sure XML5 killed DTD outright, other than having a doctype definition. Perhaps the spec was outdated a bit.

XML5 had a few big ideas:

- Ending DTD

- Unquoted XML attribs

  <elem atr1=value>
- Error recovery / arbitrary nesting which is similar to HTML

  <a><b></a></b>  // Became <a><b></a> <b/>
Re:The Goals of XML at 25: and the one change that XML now n... by skissane on Monday July 19, 2021 @05:48PM (#27887630)
> Hm, that's strange. I'm pretty sure XML5 killed DTD outright, other than having a doctype definition. Perhaps the spec was outdated a bit.

I'm just going by what is at https://annevankesteren.nl/2007/10/xml5 which gives the impression that <!ENTITY> declarations are still allowed.

Re:The Goals of XML at 25: and the one change that XML now n... by Ygg2 on Tuesday July 20, 2021 @12:55PM (#27896211)
There was a full specification that had more details. It didn't parse <!ENTITY> and similar declarations but treated it as just a dumb string.
Re:The Goals of XML at 25: and the one change that XML now n... by AlbertoGP on Monday July 19, 2021 @07:55AM (#27881577)
I agree with what you wrote except for processing instructions: I’m using them in an XML tool I’m developing for my own use, and while I could devise ways to encode them in other ways by abusing other syntax such as namespaces or (ugh!) comments, I prefer to have them available, indeed to be used sparingly.
Re:The Goals of XML at 25: and the one change that XML now n... by TedDoesntTalk on Monday July 19, 2021 @06:28AM (#27880944)
May not have been conceived that way, but it became that.

XML Schemas were the End of its simplicity.

Re:The Goals of XML at 25: and the one change that XML now n... by tragomaskhalos on Monday July 19, 2021 @12:32PM (#27884504)
Around 17 years ago I encoded some information in this little-known thing called JSON because it was more succint and generally a better fit than XML for this particular case. Even so, I'd never encountered this JSON thing before and had no idea if it had real legs or not, so it felt vaguely weird to be eschewing the Great God XML in favour of it ...
Re:The Goals of XML at 25: and the one change that XML now n... by krapp on Monday July 19, 2021 @05:22AM (#27880624)
JSON won because Javascript natively supports it, and because once the web assimilated everything, everything else had to support it.
Re:The Goals of XML at 25: and the one change that XML now n... by crispyambulance on Monday July 19, 2021 @06:36AM (#27880988)
JSON "won" because people were sick of xml, it's turgid tooling, rampant xml-abuse (the horrid ws-* ecosystem), and they were annoyed with having to edit it by hand.

That said, xml could have worked out fine if there had been sane management of it's evolution. But now the cat's out of the bag, and we got json, and the "named-to-be-a-loser" YAML.

Re:The Goals of XML at 25: and the one change that XML now n... by dkarl on Monday July 19, 2021 @04:35PM (#27887000)
This is pretty much it, JSON won because it wasn't trying to deliver on all the promises XML made. We could see that it wasn't going down that dark path. It wasn't going to attract a community drunk on visions of their markup language solving every problem that complex systems have.

Maybe someday that kind of ambition will lead to something great, but we needed a step back.

Re:The Goals of XML at 25: and the one change that XML now n... by pydry on Monday July 19, 2021 @05:55AM (#27880774)
I'm no web historian but IIRC it actually supported XML first. Calling a backend required an XMLHttpRequest call. JSON could be parsed but by "executing" it (shudder).

So, whatever reason JSON won it wasnt that.

Re:The Goals of XML at 25: and the one change that XML now n... by GoblinSlayer on Monday July 19, 2021 @03:03PM (#27886151)
IIRC execution of JSON was suggested as a parsing method, I thought it was actually a nice hack. What's the point to not reuse the javascript parser which is right there?
Re:The Goals of XML at 25: and the one change that XML now n... by konart on Monday July 19, 2021 @05:42AM (#27880715)
JSON won because it can be easily processed by a human being
Re:The Goals of XML at 25: and the one change that XML now n... by chopin on Monday July 19, 2021 @06:12AM (#27880842)
You can't comment in JSON which I don't like (to put it mildly). Any real human readable format should support comments.
Re:The Goals of XML at 25: and the one change that XML now n... by konart on Monday July 19, 2021 @01:39PM (#27885250)
valid point.
Re:The Goals of XML at 25: and the one change that XML now n... by speed_spread on Monday July 19, 2021 @04:17PM (#27886833)
That's just a matter of what you've been exposed to. While XML will always be a little more verbose than JSON, a well-designed XML document format can be much easier to read than a poorly defined JSON one. Plus, chances are that good XML also specifies a schema, which can be used by editors and tools to help you make sense of the content and rules governing it. JSON has a few schema mechanisms, but they're not integrated into the standard and thus much less supported by tooling.
Re:The Goals of XML at 25: and the one change that XML now n... by vbezhenar on Monday July 19, 2021 @04:57AM (#27880508)
I'm using XML for SOAP Web services. They are much easier to use than REST, thanks to code generation. I did not try GRPC though.

XML is awesome for configurations: with proper XML Schema and proper editor (I use Jetbrains Idea, but there are other options) you'll get almost full validation, auto-complete for free.

I would prefer XML for any markup.

JSON have one important advantage over XML without DTD/Schema: it's impossible to express array in XML. Another less important advantage is that there's only one way to stringify graph of arrays/maps into JSON. With XML there's no "official" standard, there are plenty of different ways to write maps, for example. But DTD/Schema solves those shortcomings.

Re:The Goals of XML at 25: and the one change that XML now n... by tored on Monday July 19, 2021 @06:49AM (#27881075)
You can use something like OpenAPI to get code generation for REST, but yes you have to write an OpenAPI spec for your API in YAML...

Not a fan of XML, but I think XML Schema is one of the better Schema solutions I have used. If you doing something with XML and not take advantage of XML Schema it seems like a waste.

XML for markup is okay, but usually I just use a subset of HTML5 when doing that, XML would have the benefit of having XML Schema support for validation, but I have class that can do that for me with HTML5.

Re:The Goals of XML at 25: and the one change that XML now n... by cunthorpe on Monday July 19, 2021 @05:14AM (#27880590)
Any ML can have schemas and JSON does, I don’t know what you’re talking about. What you describe is all just about support from tools, which JSON has plenty now.

The advantage that a ML can have over another is how easy it is to:

    - parse by the machine
    - read and edit by humans
Also useful but less so:

    - esoteric features like cyclic dependencies
    - size
Re:The Goals of XML at 25: and the one change that XML now n... by tored on Monday July 19, 2021 @06:38AM (#27881010)
JSON schemas are horrible though. Every implementation I tried didn't fully respect the entirety of the JSON schema specification. JSON schemas are by default non-strict, which is the opposite what you want.
Re:The Goals of XML at 25: and the one change that XML now n... by Ygg2 on Monday July 19, 2021 @05:36AM (#27880680)
Yeah, but Yaml and to some extent JSON tooling just shrivel compared to XML.

I had to edit Liquibase configs in YAML and XML. YAML was a fucking nightmare.

Re:The Goals of XML at 25: and the one change that XML now n... by pydry on Monday July 19, 2021 @05:53AM (#27880764)
XML tooling is fucking horrible.

I still get flashbacks to maintaining XSLT sometimes. It was a tool that didnt really need to exist and arguably did more harm than good by being "recommended".

I remember very clearly that although XML had tooling for schema validation it was awful and people tended not to get beyond the "DTD vs XSD" debate before giving up on it. Both of them sucked.

Then there's XPath. Why XPath? Because if your markup language doesnt map to normal programming data structures you need a band aid to fix it.

As for SOAP.... that can die in the fiery pits of hell with XMLSpy.

Re:The Goals of XML at 25: and the one change that XML now n... by Ygg2 on Monday July 19, 2021 @06:15AM (#27880863)
I said tooling was superior, not XML tooling was a silver bullet.

DTD is mostly just an attack vector. XSD or Relax NG are both solid. XQuery was kinda useful but XML people went too far and started adding shit that it doesn't belong to it.

XSLT like has one or two credible use cases, like replacing entity expansion from DTD. Rest of it was just like XML database doomed from the start.

SOAP. I never saw it actually being used.

Re:The Goals of XML at 25: and the one change that XML now n... by pydry on Monday July 19, 2021 @06:23AM (#27880914)
Superior to what, though?

Most of this tooling has equivalents that are barely used because they didnt really need to exist in the first place (e.g. XSLT) or were a band aid over problems with XML itself (XPath / XMLSpy).

That leaves JSON schema, which - still more pleasant than XSD or DTD.

Re:The Goals of XML at 25: and the one change that XML now n... by kaba0 on Tuesday July 20, 2021 @09:49AM (#27893655)
> Why XPath? Because if your markup language doesnt map to normal programming data structures you need a band aid to fix it.

How do you express easily “every element that has X in its path” with a programming language? Of course you can write such a program but it is similar to regex - you could write a FSM but it is much easier to use a DSL for that.

Re:The Goals of XML at 25: and the one change that XML now n... by TedDoesntTalk on Monday July 19, 2021 @06:33AM (#27880976)
I worked on a website that generated all HTML through XML data with XSLT templates. It was possibly the worst experience of my career.
Re:The Goals of XML at 25: and the one change that XML now n... by forty on Monday July 19, 2021 @09:54AM (#27882673)
I don't think there is only one way to stringify a given object in json. Some things that comes to mind:

- numbers are a mess. You can have the full decimal numbers, the "e" notation, and sometimes you have to use strings for number that are too big for JavaScript.

- Map keys order is not significant, so it can be any order.

Re:The Goals of XML at 25: and the one change that XML now n... by jerf on Monday July 19, 2021 @10:03AM (#27882757)
What is XML good at: https://news.ycombinator.com/item?id=11446984

The post here for your convenience:

"What is XML good at?" (For the purposes of this post, I'm including HTML in the XML family.)

XML/HTML is good when:

1. You have two dimensions of markup you want to do. That is, you have a clear distinction between what is a new "tag" and what is an attribute on that tag. If you can't almost instantly decide whether some feature you want to add works as an attribute or a tag, you probably shouldn't be in XML.

2. Almost every tag one way or another contains some text, the third dimension that XML supports. A proliferation of tags that never contain any text is a bad sign. A handful may not be a problem, e.g. "hr" in HTML, but they should be the exception.

3. You have a really good use case for XML namespacing, the fourth dimension of information that XML supports, in which case there's almost no competition for a well-standardized format, as long as you're also using the previous three dimensions.

There's sort of this popular myth that XML is useless, which I think isn't because it's true or that XML is bad, I think it's because in general, most times you want to dump out a data structure #1 isn't true, let alone #2 or #3. In a lot of data sets, you've only got the two dimensions of "simple structure" and "text", not annotations on the structure itself. (Or, perhaps even more accurately, they end up implicit in the format itself, and the format is constant enough for that to be just fine.) A lot of stuff in the 1990s and 200xs used XML "because XML" even though it clearly failed #1. XML is really klunky when you don't want that second dimension because the XML APIs generally can't let you ignore it, or they wouldn't actually be XML APIs.

On the other hand, when you learn this distinction, you do come across the occasional JSON-based format that clearly really ought to be XML instead. You can embed anything you want into JSON, but when you're manually embedding a second structure dimension into your JSON document, it loses its advantages over XML fast. If you've ever seen any of the various attempts to fully embed HTML into JSON, without leaving any features behind, you can begin to see why XML or XML-esque standards like HTML aren't a bad idea. HTML is much easier to read for humans than HTML-in-JSON-with-no-compromises.

And if you've truly got the four-dimensional use case, XML is really quite nice. When you need all the features, suddenly the libraries, completely standardized serialization, and XPath support and such are all actually convenient and surprisingly easy to use, for what you're getting.

Some examples: HTML is a generally good idea. SVG is a middling idea; it passes #1 and #3 but fails #2. SOAP and XML-RPC is generally a bad idea; SOAP fails #1 and #2 but sort of uses #3 and XML-RPC fails all three. XMPP I actually think is pretty solid as an XML format (mere network verbosity problems can be solved with an alternate encoding, though admittedly that becomes non-standard), and in a lot of ways, the real problem with XMPP isn't so much the format itself as that people are not used to dealing with the four-dimensional data structures that result. People expecting IRC-esque flat text are not expecting such detail. Using the fourth dimension of namespaces for extensibility is neat, but few developers understand it, or want to.

Re:The Goals of XML at 25: and the one change that XML now n... by tannhaeuser on Monday July 19, 2021 @10:25AM (#27882951)
I find the hoops that people are jumping through to rationalize element-vs-attribute use fascinating.

How about: markup languages are good for encoding text, and everything that isn't directly part of text content ("metadata") goes into attributes? Arrives at about the same judgement regarding the relative merit for the use cases you mentioned.

I'd like to add that, while XMPP is XML-based, it might be more suitable to use a full-blown SGML parser to deal with XMPP streams being presented as incomplete XML (eg end-element tags missing) which SGML can deal with in a formal way (end-element inference).

Re:The Goals of XML at 25: and the one change that XML now n... by MattJ100 on Monday July 19, 2021 @10:43AM (#27883192)
> I'd like to add that, while XMPP is XML-based, it might be more suitable to use a full-blown SGML parser to deal with XMPP streams being presented as incomplete XML (eg end-element tags missing) which SGML can deal with in a formal way (end-element inference).

It's not that end tags are missing in XMPP, just that the "document" is streamed so it isn't all available at once. Any common SAX-style parser can deal with streaming documents.

https://en.wikipedia.org/wiki/Simple_API_for_XML

Re:The Goals of XML at 25: and the one change that XML now n... by bryanrasmussen on Monday July 19, 2021 @10:45AM (#27883203)
4. You need to have a relatively small number of humans who are specialists in some domain edit some large structured format that will be consumed by a computer. Thus you probably need an XML editor and the validation tools XML supports, rather than trying to roll your own.
Re:The Goals of XML at 25: and the one change that XML now n... by Mikhail_Edoshin on Tuesday July 20, 2021 @01:01AM (#27890243)
Elements without text in XML are totally fine. You still get the expressive power of composition and ordering. You do need to have text if the document has actual text, but if it's not (e.g. a drawing), then all its syntax belongs to machine domain.
Re:The Goals of XML at 25: and the one change that XML now n... by deepstack on Monday July 19, 2021 @05:53AM (#27880767)
the only thing I can think is have binary data to be part of the document . I guess one can also use base64 string in JSON.
Re:The Goals of XML at 25: and the one change that XML now n... by tester34 on Monday July 19, 2021 @05:17AM (#27880600)
I believe XML is too complex

Also: why the fq order matters

Re:The Goals of XML at 25: and the one change that XML now n... by chopin on Monday July 19, 2021 @06:14AM (#27880859)
I think you can define your schema such that order doesn't matter. And for stream processing large xml files imposed order may come handy to avoid a second pass.