Attributes and Namespaces
An attribute name can be used only once in an element. When you combine a namespace prefix with an attribute name, the combination must be unique. The following is acceptable:
<?xml version="1.0"?>
<message xmlns='http://www.northwindtraders.com/bill'
xmlns:body='http://www.northwindtraders.com/message'>
<date>1/1/2002</date>
<body:body body:importance='High' importance='High'>Your current
balance is $1,999,999.00. Please pay immediately. Thank you.
</body:body>
</message>
|
In this case, the first importance attribute is associated with the body namespace, and the second importance attribute is associated with the default namespace.
Remember, you can define an element name only once in your DTD. Namespaces resolve the element naming conflicts. By using namespaces, you can reference several different documents that all use the same element names.