NAME SPACE
XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary. A namespace name is a uniform resource identifier (URI). Typically, the URI chosen for the namespace of a given XML vocabulary describes a resource under the control of the author or organization defining the vocabulary, such as a URL for the author’s in the Web server.
Table Of Content :
- XML NameSpace Introduction:
- XML NameSpace Advantages:
- XML NameSpace Disadvantages:
- XML NameSpace Example:
XML NameSpace Introduction:
- It is used to avoid element name conflict in XML document.
- It is a set of unquie names.
- Identified by URI (Uniform Resource Identified)
- Attributes names must start form with "xmlns",
- Syntax:
- Conflict: Genrally conflict occures when we try yo mix XML documents from diffrence XML applications.
- Example of Conflict:
- XML1
- <class><name>..........</name></class>
- XML2
- <class><name>..........</name></class>
- So, In this case same name parent and child then create a conflict occuress due to same..
XML NameSpace Advantages:
There are some advantages of XML Namespaces:
- It avoids duplicate element names and attributes defined in an XML document where the XML element defined in one organization product may conflict with the other.
- With namespace elements and attributes can be reused in other documents or schema without any error.
- It enhances readability and the declaration of them is placed anywhere within an XML document.
XML NameSpace DisAdvantages:
Here are some disadvantages of XML Namespaces:
- XML documents are less readable when compared to other text-based data transmission formats.
- XML namespaces are difficult to use and cannot be correctly implemented in an XML parser.
XML NameSpace Example:
<? xml version ="1.0" encoding="UTF-8" ?>
<c1:class xmlns:c1="#class1//url.......">
<c1: name> Shailesh<c1: name>
</c1: class>
<c2: class xmlns:c2="#url Class....">
<c2:name>Shailesh<c2:name>
</c2:class>
So : No There will be no conflict due to namespace
So. I hope this is helpful for YOu . Thanks For Comming Back.
Comments