Download presentation
Presentation is loading. Please wait.
1
XML Namespaces Andrey Smirnov CSCI 7818 September 21, 2000
2
Overview Why do we need Namespaces in XML? Definition of Namespace. How do we specify Namespaces? Questions.
3
Why Namespaces? The purpose of XML Namespaces is to distinguish between duplicate element and attribute names. For example: $ Both “sedans” and “trucks” have the same “price” element, so the parser doesn’t know which one is which.
4
Definition Namespace is a mapping between an element prefix and a URI –cars is the prefix in this example, –URIs are not a pointer to information about the Namespace. They are just unique identifiers. You cannot resolve XML namespace URIs.
5
Ways to Specify Namespaces Inside the XML file. Inside the DTD file.
6
XML File Specify a Namespace for every element.
7
XML File Specify all Namespaces within the root element. The specification given for the that element is also valid for all elements occurring inside it.
8
XML File Namespaces do not have to be specified explicitly with prefixes. The attribute xmlns defines the default namespace which is used for the element.
9
XML File Attributes can be explicitly assigned a value and be associated with a Namespace by using prefixes.
10
XML File Attributes without a prefix do not belong to any Namespace.
11
XML File A Namespace specification can be overridden using the prefixes. It’s uppercase now.
12
DTD File Here is a sample Namespace specification within a DTD. <!ATTLIST cars xmlns:part CDATA #FIXED “http://www.w3.org/1999/cars”>
13
Questions Any questions? Any comments?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.