I am currently a uni student, and I have to admit that I find most of the classes a waste of time. I often find myself being taught what I consider to be redundant technology practices when more superior ones are being used by the industry. Having said that, it turns out I’m not always right. One of my classes was on XML’s use for database and web services, and one of the first techniques taught to us was XSD (AKA XML Schemas). As I was doing this I was thinking “XML to define XML… this is just ridiculous”, but eventually after giving a go, I was pleasantly surprised by some of its uses, so much so that I am now attempting to use in practice.
One of the apps I have been working on lately has had a lack of communication between the developers of the web service and the developers of the iOS client that feeds on the web service. Such miscommunication can lead to many frustrated hours of debugging. With XSD validation on both the web service as it is going out of the server and coming into the client gives the client confidence that the XML is formatted exactly the way it should be. Now I am not sure if there is an equivalent for JSON, if there is I would recommend you use that because JSON seems to be becoming the standard these days, and I’ll admit XML web services are becoming older technology.
XSD isn’t just good for validation though. If you were around at the start of the century you would be familiar with the direction web services were heading with technologies such as SOAP and WSDL, where code generation would rein supreme. Using just an XSD, we can turn XML strings into C++ traversal objects, using libraries such as CodeSynthesis to completely automate the parsing of XML files (although we at B2Cloud won’t be using it as we cannot adhere to the GPL on commercial products, but I am sure there are plenty of other alternatives).
Compared to the way I used to handle web services using the NSXMLParser this way offers much better compatibility and reliability. Whenever I have to use or design an XML web service, from now on I will be using XSD to assist me.