3 ms·
Last time I checked, XML was uncertain which validation should I use. DTD, Schema, other solutions. Each has syntax/structure and 1st page explanation so crypti
by wruza 9y ago
Last time I checked, XML was uncertain which validation should I use. DTD, Schema, other solutions. Each has syntax/structure and 1st page explanation so cryptic, that I don’t even understand where do I begin.
I don’t like js/json at all, but for json (and without much js knowledge) I can roll out simple validation in less time than is needed to understand these schema formats. If my structure is dynamic, omg it will be hard to explain it to declarative validator. If it contains value-level type logic (graphs, references), I bet second phase of validation by hand is inevitable anyway.
A second thing, full-blown xml is alien to any structures of simple languages and cannot be serialized like jsonlib.encode(foo). You create nodes, set attributes, build trees, all that mess. It feels like using a 17th century official mail ceremony to send “)))” to your buddy.
- mpweiher 9y ago> and cannot be serialized like jsonlib.encode(foo) Huh? Could have fooled me. In Cocoa, for example, serializing to JSON and serializing to an XML property list (or binary property list) is effectively the same code. https://developer.apple.com/documentation/foundation/nsjsonserialization?language=objc https://developer.apple.com/documentation/foundation/nsjsons... https://developer.apple.com/documentation/foundation/nspropertylistserialization?language=objc https://developer.apple.com/documentation/foundation/nsprope...
- wruza 9y agoYes, but property list is a subset of XML and Cocoa’s almost internal format. It doesn’t even connect keys to values, probably losing all the xpath/xslt/etc abilities. No custom schema too?
- mpweiher 9y agoHmm...since XML is a meta-language describing a family of markup language[1], every actual XML-based language will be a "subset". And of course that is why some of the XML tools are so heavy: they deal with the full meta-format. The "nice" thing about JSON is that it doesn't have this indirection step, it's just one concrete language, and that's why it is simple. But again, it's trivially easy to define an actual concrete markup language using XML that is just as simple. I agree with you that the choice of <key>theKey</theKey><string>value</string> rather than <theKey>value</theKey> was regrettable, had I designed the format I would have chosen differently. I think they wanted one DTD to describe this format, which wouldn't have been possible without keeping the meta-level indirection. I created XML-based archivers for Cocoa that don't have this problem[2]. Again, this wasn't hard, and the API is NSKeyedArchiver compatible, so [MPWXMLArchiver archivedDataWithRootObject:someObject]; gets you a nice XML representation. [1] http://www.xml.com/pub/a/98/10/guide0.html?page=2 http://www.xml.com/pub/a/98/10/guide0.html?page=2 [2] https://github.com/mpw/Objective-XML/blob/master/MPWXmlArchiver.h https://github.com/mpw/Objective-XML/blob/master/MPWXmlArchi...
- Thiez 9y agoYou can still use XPath/Xslt in that scenario, it's just more annoying. Of course it wouldn't be hard to write an Xslt to rewrite the XML so that the keys and values are better connected, so you can query it more easily using XPath.
- josteink 9y ago> Last time I checked, XML was uncertain which validation should I use. DTD, Schema, other solutions DTD was considered obsolete more than a decade ago. Nobody uses anything but XSD nowadays.