我正在尝试理解XML命名空间约定(使用URI进行命名空间)。我已经阅读了StackOverflow上的这个帖子。我明白命名空间的全名应该是唯一的。但我仍然不明白为什么我们不能只使用随机字符串?例如,我们正在尝试在文件中区分真正的汽车和玩具汽车。
使用第二种方法可能会带来哪些负面后果?是否有任何现实生活的例子?
<?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>
如果有人能解释一下为什么选择这个选项,我会非常感激。
xmlns:real="http://cxf.apache.org/jaxws/cars/real"
比这个更好:
xmlns:real="heroigairehgoiaer7272"
使用第二种方法可能会带来哪些负面后果?是否有任何现实生活的例子?
urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66
。 - unor