I heard that the XML DTD has less constraints in place (esepcially for the datatypes) than the XML Schema, and was wondering if this lack of constraints can make something expressed in XML DTD very buggy, but re-expressing it in the XML Schema solves the problem.

For example, if someone tries to input their name in numbers in the XML DTD, would that cause problems for the XML DTD but not for the XML Schema due to the constrained datatypes?

Example cases and codes would be highly appreciated.

1

There are 1 best solutions below

0
Michael Kay On

I don't know what you mean by "buggy".

An XSD schema can express more constraints on document content than a DTD can express. Schematron can express more constraints than an XSD can express. That doesn't make any of these technologies (or any applications that use them) buggy.

If people enter incorrect data, that doesn't "cause problems" for the validation technology. It might cause problems for the downstream application that uses the data, or for a human being who uses the data, but that's not the same thing.

Remember that validation doesn't imply the data is correct. You can have all the validation rules in the world, and people will still be able to send you data claiming that their name is Mickey Mouse. Validation is there to catch some errors, and it's not buggy if it doesn't catch all of them.

Also, validation generally refers to the internal consistency of a message. An application that processes that message will generally do further checking to ensure that the contents of the message are consistent with other known facts.