I'm trying to understand the reasons of the XML-namespaces convention (using URI for namespaces).
I've read this thread on StackOverflow. I understand that namespace's fullname should be unique. But I still don't understand why can't we just use random strings for this?
For example, we're trying to distinguish the real cars from the toy cars in our file:
<?xml version="1.0" encoding="UTF-8"?>
<carstore xmlns:real="http://cxf.apache.org/jaxws/cars/real" xmlns:toy="http://cxf.apache.org/jaxws/cars/toy">
<real:car category="truck">
<model lang="en">Scania R 770</model>
<year>2005</year>
<price currency="US dollar">200000.00</price>
</real:car>
<toy:car category="sedan">
<title lang="en">Ford Focus</title>
<year>2012</year>
<price currency="US dollar">100.00</price>
</toy:car>
</carstore>
<?xml version="1.0" encoding="UTF-8"?>
<carstore xmlns:real="heroigairehgoiaer7272" xmlns:toy="289ry89fhfhbvnsdkljnv">
<real:car category="truck">
<model lang="en">Scania R 770</model>
<year>2005</year>
<price currency="US dollar">200000.00</price>
</real:car>
<toy:car category="sedan">
<title lang="en">Ford Focus</title>
<year>2012</year>
<price currency="US dollar">100.00</price>
</toy:car>
</carstore>
I'll be grateful if someone will explain why this option
xmlns:real="http://cxf.apache.org/jaxws/cars/real"
is better than this one:
xmlns:real="heroigairehgoiaer7272"
What negative consequences can we face using the second one? Probably there is any real-life examples?
Random, unique, strings could be used for namespace values, however...