5 ms·
While it's true that XML is a generic serialization of angle-bracket markup that doesn't need a schema for serialization (which was exactly the main motivation
by tannhaeuser 6y ago
While it's true that XML is a generic serialization of angle-bracket markup that doesn't need a schema for serialization (which was exactly the main motivation for its "invention" as a SGML subset), the reason it's being used in inter-party or long-term/loosely-coupled service payload serialization is because it has fairly powerful and well-established schema languages (XML DTDs and XML Schema) for validation. This is unlike JSON which thrives in ad-hoc serialization for tightly-coupled back-ends and web front-ends (and only in that scenario IMHO). So I don't think XML belongs into the "schema-less, copying" category.
- randombytes6869 6y agoVery true. IMO many people that hate XML config files just haven't used an IDE that validates schema. Its super nice to have auto-complete and property validation on config files, something not offered by JSON or YAML. A good reason to stick with XML for complicated configs. Its one of reasons I don't mind maven. Yeah there's 1000+ line XML config file, but maven DTD is so tight nearly any syntax issue will be flagged. Something easy to appreciate when you're used to giant config files that don't get validated until runtime.
- Negitivefrags 6y agoVisual studio does schema validation for JSON and gives errors inline. There is a big list of supported schemas built in and you can define your own. Never actually looked at the format personally.
- nojvek 6y agoJson schema is what vscode uses. It’s a standard nowadays. Just as effective as XMLSchema. https://jsonschema.net/ https://jsonschema.net/ http://www.schemastore.org/json/ http://www.schemastore.org/json/
- tannhaeuser 6y agoWhile I generally agree, I'm not sure maven's pom.xml (aka porn.xml), of all things, is a paragon of good markup design ;) For one, maven actively forbids/rejects use of ordinary XML entity references, and invents its own text expansion instead (so strictly speaking pom.xml isn't even XML proper). Then using XML for a relatively simple EAV format seems like overkill. But yeah, over a decade ago the maven developers had great plans to open up the format for alternative serializations/DSLs; thankfully they didn't, if only because they realized it isn't worth the maintenance effort. I'll add that a format for describing software builds is probably the wrong place to let a thousand blossoms bloom, something that you realize soon enough if you've worked as freelancer in Java-ish project's for any amount of time, and where every other project is feeling the urge to use the oh-so-great gradle as an alternative to pom.xml. My comment was only aimed at service payload serialization; as to whether markup makes for a good config file format, I'm not entirely sure. It certainly is better than inventing an ad-hoc format IMO, but OTOH there are a couple of not-quite-SGML/XML config formats such as Apache's httpd.conf, or in fact maven's that just give XML/SGML a bad name IMHO, because they generally inherit the downsides of markup without bringing its benefits (such as being able to assemble a configuration from fragments using regular entity expansion).
- vbezhenar 6y agopom.xml is not a great example of proper XML use. For example maven should utilize additional namespaces for plugin configurations, but it does not.
- dottedmag 6y agoSchema-less and schema-ful are better be split into schema-for-parsing, schema-for-validation, no-schema-invented-yet.
- mintyc 6y agoOr even schema-for-type, schema-for-value-validation Just as an aside. The new version of OpenAPI (v3.1 RC) for REST interfaces now fully supports the json-schema validation mechanism so we may see an uptake in use of json schema. Its not perfect and has some holes.
- secondcoming 6y agoJsonschema exists. https://json-schema.org/ https://json-schema.org/
- tasogare 6y agoThis is a later creation, not yet even finalized.
- secondcoming 6y agoIt works though.
- partyboat1586 6y agoIt was used in multiple production systems I have worked on. Look at the number of DLs on this JSON schema validator https://www.npmjs.com/package/ajv https://www.npmjs.com/package/ajv