4 ms·
>that code could have gotten the list of allowed country names from a file, database, or URL. That is exactly the point. You should be able to do that, because
by crdoconnor 9y ago
>that code could have gotten the list of allowed country names from a file, database, or URL.
That is exactly the point. You should be able to do that, because the canonical list of data could easily from any of those and it should the up to programmer's discretion how to fetch it.
The point of validation is to prevent invalid data from slipping through a net at minimum cost and that's how you do that.
Suden, Sudaan and South Sudan were all invalid countries in 2010 and that YAML was invalid. In 2012, Suden and Sudaan were invalid but South Sudan was not so that YAML was valid.
In the above example you have to make no code changes in order to account for that - just update pycountry every so often.
With XML schemas and DTDs either you don't validate country at all (letting Suden and Sudaan) through the net. Or, you rewrite and redistribute the schema by hand every time some dependency like a list of countries changes.
>If I have to send such json to you, I almost would have to write my program in python
Only if I choose to validate that data using a shared schema. Frankly, I've dealt with XML a lot and the number of times I've been handed a shared schema of any kind is very low. People just don't seem to use them. If they define an API in XML for instance they tend to just send examples and give a written explanation (e.g. insert valid country name here).
I don't see much value in making a schema more inherently "shareable" especially not if it means it has to be re-released every month.