What is a XML schema in plain simple terms? What will be the problem if an XML doesn't have a schema defined? An example can be very helpful.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
The main problem I see is that it cannot be validated either against a DTD, or against an XML Schema. As such, you don't have any guarantee that what you received is what you expected.
For example, if you are sending this XML file to someone:
How can he be certain that:
There is an unlimited list of questions that person can ask to you. The goal of an XML Schema is to hopefully answer all these questions and also to provide a way to validate a document before or during the parsing phase.
Not fond of w3schools, but here is a list of short and interesting reads on XML Schema:
It's the same question as using a static or dynamically-typed language. Schema is a declarative check on the correctness of your data. If you have a field that has to be an integer, you can mark as such in your schema and then invalid data won't get past the validator. Without a schema, you would have to check in your code which is more error-prone. Sometimes, you might have a preference for flexibility in which case a schema is a hindrance. Notably there is no standard schema language for JSON, yet it is growing in popularity.