5 ms·
> I think that XML's bad reputation comes from the fact that it is <adverbial-particle modifies="#123">so</adverbial-particle> <adverb id="123">incredibly</adve
by JoshTriplett 10y ago
> I think that XML's bad reputation comes from the fact that it is <adverbial-particle modifies="#123">so</adverbial-particle> <adverb id="123">incredibly</adverb> <adjective>verbose</adjective>.
> Also, the whole child/attribute dichotomy is a huge, huge mistake.
Those two factors run counter to each other. Attributes decrease verbosity, compared to child elements.
I agree, though. A few changes would make XML closer to ideal: eliminate attributes and eliminate the name in closing tags (<tagname>value</>), which makes child elements much less verbose, and reduces the need for attributes.
- wtbob 10y ago> A few changes would make XML closer to ideal: eliminate attributes and eliminate the name in closing tags (<tagname>value</>), which makes child elements much less verbose, and reduces the need for attributes. Then just change '<tagname>' to '(tagname,' and '</>' to ')' and you'll have S-expressions. Consider this: (feed (version 1) (title "Example Feed") (link http://example.org/) (updated "2003-12-13T18:30:02Z") (author (name "John Doe")) (id urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6) (entry (title "Atom-Powered Robots Run Amok") (link http://example.org/2003/12/13/atom03) (id urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a) (updated "2003-12-13T18:30:02Z") (summary "Some text."))) That is a canonical S-expression (for a Scheme or Common Lisp reader, just quote the URIs too) version of: <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Example Feed</title> <link href="http://example.org/"/> <updated>2003-12-13T18:30:02Z</updated> <author> <name>John Doe</name> </author> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> <entry> <title>Atom-Powered Robots Run Amok</title> <link href="http://example.org/2003/12/13/atom03"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <summary>Some text.</summary> </entry> </feed> I particularly like how URIs are sometimes encoded as attributes and sometimes as child text elements. And compare to your proposed version: <feed> <title>Example Feed</> <link>http://example.org/</> <updated>2003-12-13T18:30:02Z</> <author> <name>John Doe</> </> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</> <entry> <title>Atom-Powered Robots Run Amok</> <link>http://example.org/2003/12/13/atom03</> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</> <updated>2003-12-13T18:30:02Z</> <summary>Some text.</> </> </> I think it's pretty clear which is the most readable and elegant.
- JoshTriplett 10y agoIf you're going to compare the two fairly, include appropriate indentation for both, not just the S-expression version. Also put the author and name tags on the same line, as you did with the S-expressions: <feed> <title>Example Feed</> <link>http://example.org/</> <updated>2003-12-13T18:30:02Z</> <author><name>John Doe</></> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</> <entry> <title>Atom-Powered Robots Run Amok</> <link>http://example.org/2003/12/13/atom03</> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</> <updated>2003-12-13T18:30:02Z</> <summary>Some text.</> </> </> That said, I like S-expressions too, and I wish more parsers and tools existed for them, such as schemas, query tools, and simple transformation tools.
- wtbob 10y ago> If you're going to compare the two fairly, include appropriate indentation for both, not just the S-expression version. When I pasted it in from https://validator.w3.org/feed/docs/atom.html#sampleFeed https://validator.w3.org/feed/docs/atom.html#sampleFeed I guess I lost the indents. No idea why: they are clearly there in the original.
- erlehmann_ 10y agoThe second and third examples do not have namespaces. How would you include an HTML summary, for example?
- wtbob 10y ago> The second and third examples do not have namespaces. > How would you include an HTML summary, for example? As a text attribute, honestly — which would be necessary in XML as well (you could embed XHTML in XML, but not HTML). And in the general case, embedding one variant of XML inside another, rather than embedding a character-encoded variant of XML inside another, doesn't seem all that useful. How often do transforms need to reach all the way in like that? I guess it's cool if it's possible, which is why I like S-expressions all the way down. But I don't think it's all that useful, as opposed to neat.