XML is well regarded in the enterprise and languages like JAVA, C#, and VB.NET handle is spectacularly as an exchange format. I think it's bad reputation comes from anyone not using an enterprise language because the support just isn't there. I recall working with a partner who we were doing an identity federation with. Our system was using WS-Trust which is a SOAP/XML protocol. It wasn't ideal but everyone seemed to…
How to Avoid Being Called a Bozo When Producing XML (2005)
21–30 of 255 posts
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#22Example usage: https://github.com/libguestfs/libguestfs/blob/master/src/lau...
Macro definitions: https://github.com/libguestfs/libguestfs/blob/master/src/lau...
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#23Why would anyone choose to use XML over JSON, other than for RSS?
I can parse/print XML (using either in memory parser or streaming parser), use XML Schema to validate XML, XPath expressions to select necessary parts, automatic object mapping, and that's all with standard library without a single external dependency in Java. I don't know why would I use JSON over XML, unless I have very good reasons to do so. For me the only thing that JSON got better is that JSON is directly mappe…
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#24This is by no means totally bulletproof, but these C macros around libxml2 let us write nested well-formed XML expressions as code: Example usage: https://github.com/libguestfs/libguestfs/blob/master/src/lau... Macro definitions: https://github.com/libguestfs/libguestfs/blob/master/src/lau...
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#25> Don’t print > Use an isolated serializer Some old reference material (XML isn't as common as JSON anymore), but still worthwhile learning: don't output data formats directly. Directly = echo, print, printf,println...whatever your syntax suggests. I see this happen a lot with my junior engineers, and I have this same conversation with them. Prefer to use data serializers that encapsulate all the syntactical rules th…
It's a classic trap that appears to get software developers caught (even now in 2016!) at that point where you are still lacking that firm grasp of the standard libraries available to you.
The single greatest strength of a skilled software engineer is to know when to make it someone else's problem.
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#26Back in the early days of XML, Internet Explorer would insert "+" characters to fold nested sections of XML. And was the default program to open .xml files. Guess what showed up in the documents I got from an integration partner?
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#27This is by no means totally bulletproof, but these C macros around libxml2 let us write nested well-formed XML expressions as code: Example usage: https://github.com/libguestfs/libguestfs/blob/master/src/lau... Macro definitions: https://github.com/libguestfs/libguestfs/blob/master/src/lau...
Totally, we took this a step further and created a subversion repository where xml documents describe classes. Each method is either inline, or is described by a xml element of a particular namespace that links to a subversion id and revision. ;)
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#28The author of this post is a bozo, doing any (or not doing any) of the suggested things does not guarantee well formed XML. Disregarding whole sections of the XML spec, prescribing a certain way to generate xml are more harmful than not. Can text templates generate well formed xml, absolutely. Can tools generate non-well formed xml, absolutely.
He states why right there. He doesn't say anywhere whether templates can or cannot generate well-formed xml.
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#29Why would anyone choose to use XML over JSON, other than for RSS?
I'll add some more reasons to the flamebait: - JSON doesn't have namespaces, making integration of different data-sources quite hard. - XML allows me to do versioning within documents. - An extremely large corpus of well-tested libraries are available. - As opposed to JSON, XML and accompanying standards (XSLT, XML Schema, XPath, XQuery) are extremely well documented. - XML validation, parsing and processing can happ…
>JSON doesn't have namespaces, making integration of different data-sources quite hard.
Yeah, and how often do you merge two data formats like that into one data format in a way that doesn't require massive transformations anyway?
>XML allows me to do versioning within documents
Well, that's fantastic. Because XML is designed for DOCUMENTS. But JSON is designed as a wire protocol, and a data exchange format, which is very different. You shouldn't use JSON for documents, and I very much doubt that's what OP was talking about.
>An extremely large corpus of well-tested libraries are available.
For your language. But XML is fairly complex, and there are a lot of environments with no support, and JSON parsing is so simple and easy that the complete grammar, as well as the semantics, are on the front page of the website, and it's unlikely your language doesn't have support for it already.
>As opposed to JSON, XML and accompanying standards (XSLT, XML Schema, XPath, XQuery) are extremely well documented.
The grammar and semantics are on the front page of the site. And JSON is simple enough there's little more to it than that.
>XML validation, parsing and processing can happen at the same time, allowing streaming solutions. Using the XML schema, a parser can be created which is optimized for a specific stream of data.
Really? That's actually kinda cool. :-)
Re: How to Avoid Being Called a Bozo When Producing XML (2005)
#30Why would anyone choose to use XML over JSON, other than for RSS?