Professional Documents
Culture Documents
XMLNamespaces
XMLNamespaces
Andrey Smirnov
CSCI 7818
September 21, 2000
Overview
• Why do we need Namespaces in XML?
• Definition of Namespace.
• How do we specify Namespaces?
• Questions.
Why Namespaces?
The purpose of XML Namespaces is to distinguish
between duplicate element and attribute names.
For example:
<vehicles>
<sedans><price>$</price></sedans>
<trucks><price>$</price></trucks>
</vehicles>
<aaa >
<bbb xmlns = "http://website/lowercase“>
<ccc />
</bbb>
<BBB xmlns = "http://website/uppercase" >
<CCC />
</BBB>
</aaa>
XML File
Attributes can be explicitly assigned a value and be
associated with a Namespace by using prefixes.
<lower:aaa xmlns:lower="http://website/lowercase">
<lower:bbb>
<lower:ccc xmlns:lower="http://website/uppercase">
<lower:ddd>It’s uppercase now.</lower:ddd>
</lower:ccc>
</lower:bbb>
</lower:aaa>
DTD File
Here is a sample Namespace specification within a DTD.
<!ELEMENT cars>
<!ATTLIST cars
xmlns:part CDATA #FIXED “http://www.w3.org/1999/cars”>
Questions
• Any questions?
• Any comments?