3 ms·
XML was a bad fit for almost everything people did with it. The natural data model of XML is alien to all programming languages people use: it is alien to scrip
by EdiX 4y ago
XML was a bad fit for almost everything people did with it. The natural data model of XML is alien to all programming languages people use: it is alien to scripting languages because you want hashmaps and lists and it is alien to static languages because you want structs and lists.
So you usually ended up having to have a two stage parser, with the first stage turning XML into some kind of DOM and then your handrolled DOM-to-internal-representation thing.
That's also most of the justification for XML's ecosystem:
- You need XSD to make sure that your DOM-to-internal-representation code doesn't have to deal with garbage
- You need XPath to query XML directly if you don't want to convert it to something usable
- You need XSLT as a scripting language where the DOM isn't alien and awkward to manipulate
This is why there is no xslt equivalent (although you could argue that jq is that) and the various json schema solutions don't see much adoption, despite json being almost as old as XML at this point.
- lp4vn 4y agoHonestly I don't agree with you, the abstract concept behind XML is just to provide a metalanguage for the representation of hierarchical data, and that's exactly what JSON and YAML do. They are completely interchangeable. XML is the general case for hierarchical data and provides tools for this general case. JSON got closer to the representation of list and hashmaps, but I see this as a mere convenience. >This is why there is no xslt equivalent (although you could argue that jq is that) and the various json schema solutions don't see much adoption, despite json being almost as old as XML at this point. I think it's incorrect to part from the assumption that nobody's gonna need a schema language, a query language, a mapping language or whatever. For the json schema this is blatantly untrue and you see many people creating their own version of a json schema because it's really needed. With XSLT you have a language for processing XML that's written in XML itself, what I find pretty nice. We're not gonna see a YAML processing language written in YAML any time soon though.
- tannhaeuser 4y ago> the abstract concept behind XML is just to provide a metalanguage for the representation of hierarchical data No it isn't, for the umpteenth time. It is a language for marking up text. Markup language deal with grammars - data serialization not data models, and if anything, having regular content models is a more characteristic property for markup languages compared to hierarchy.
- EdiX 4y ago> the abstract concept behind XML is just to provide a metalanguage for the representation of hierarchical data What you are describing here is s-expressions, XML represents a far more specific type of data structure: a tree of nodes where each node is either a text node or a tag node. Text nodes are always terminal, tag nodes can either be terminal or not. Tag nodes also have a list of attributes, while text nodes do not. Each attribute is a key value pair where both the key and the value are text, but the key can only contain certain characters, whereas the value is unrestricted. This is all fairly complicated and it doesn't really map well to almost anything. Even the description is longwinded. You say: > JSON got closer to the representation of list and hashmaps, but I see this as a mere convenience I say that calling it "mere" convenience is underselling it. The data model of XML is of so little use that no programming langauge, besides XSLT, offers it as part of the language. Vice versa hashmaps and list are nearly universal. > I think it's incorrect to part from the assumption that nobody's gonna need a schema language, a query language, a mapping language or whatever I didn't say that. I said that with XML the need for those tools is especially pressing because XML is such a poor fit for any programming language. > you see many people creating their own version of a json schema because it's really needed Sure, but you also see very low adoption for json schema, because it isn't needed as much as xml schema was.
- kaba0 4y agoSo object graphs are rare in your opinion?
- butlerm 4y agoI fail to see why any typical use of XML _needs_ XSD, XPath, or XSLT. You certainly don't need XSD validation. It is trivial with stream processing to detect, skip over, and report on elements that shouldn't be there and every general purpose XML alternative has exactly the same issue, if not a worse one through use of eval style import of objects of questionable provenance. Then you have no idea what your object structure now imported natively in your language contains, and you would have to post process it for vulnerabilities using introspection to find out. In my view there just is no substitute for careful analysis of data submitted by any third party, and parsing an object into a tree structure and validating it after the fact is a questionable practice with untrusted data from anywhere. It may consume an arbitrary amount of resources before you have any idea whether the data in question bears even a passing resemblance to what it is supposed to be. If you have untrusted data you really shouldn't be using an unrestricted DOM constructing parser or eval style processing at all.