answersLogoWhite

0

Why namspace used in xml?

User Avatar

Anonymous

12y ago
Updated: 8/20/2019

The namespace in XML is used to prevent tag naming collisions.

Because XML is a meta-language that allows you to define your own elements and attributes, there is significant concern that both you and I might define an element with the same name. For instance, let's imagine that you've created a DTD (Document Type Definition -- the definition file of an XML language) which allows you to define where people sit in a banquet hall. Further, let's pretend I'm hosing a Poker Tournament at your banquet hall.

In both DTDs, we have an element called "table." But they mean different things. If we tried to use both DTDs together, a hot mess would ensue. You're data type wouldn't validate against my DTD, and vice versa.

So we use namespaces. In XML, we use a namespace by adding the xmlns attribute (that's XML Namespace.) The attribute takes a unique URL as it's value. It's important to note that this value is simply for uniqueness (in other words, it doesn't have to exist. The XML parser will not go looking for it.)

I can now attach my namespace directly to my table elements:

<table xmlns:p = "http://www.example.com/pokerTable">

...

</table>

Further, I define a "prefix" which in this case is p. Now, I can use the prefix when I add a tag. For instance

<p:seat>Data</seat>

You would use a separate prefix and xlmns value, and this would keep us from stepping on each other's toes.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What is the difference between xslt and xml?

XML is a language used to store data. XSLT is a language which is used to transform XML into other XML.


What is deployment descriptor in xml?

used for xml mappings


Why xsd is used in xml schema?

An xsd is used in an xml schema as a blueprint to define what can and cannot be included in an xml file.


Which language used in xml?

xml is a meta language which means it is a language to describe data, their is no language per se that is used in xml, xml is simply plain text.


Can XML be used to for data storage?

Yes, XML can be used for data storage. XML store data in the form of nodes and sub-nodes.


Can xml be used to access data?

xml can be used with other technologies to access a database but xml is not a programming language on its own so cant access a database.


What is difference between XML property and XML dimension?

The xml property returns the XML of a node and its descendants.Dimension is a type used for a variety of purposes for defining values


Why is XML Parser used in modern browsers?

XML Parser is used to decipher XML codes. Without it, the codes cannot be understood. Web browsers, such as Mozilla Firefox and Google Chrome supply the user with this XML Parser.


What are xml and dtd?

xml stands for extensible markup language, xml is a markup language that is used to transfer data / information. Dtd stands for document type definitionand dtd is used to define the legal building blocks of an XML document.


What is the XML database used for?

xml is used on webpages and web services and can also be used to create data bases and to store and carry data.


How does xml works?

xml is a markup language that is used ti dispplay data and web pages as intended. XML has no semantic menating and you create your own tags in accordance with xml specifications.


How is a computer XLM file used?

By the way, it's called a XML file, which stands for Computer Markup Language. An XML file is a set of rules used for encoding documents electronically. It is common for XML to be used in interchanging data over the Internet. RFC 3023 gives rules for the construction of Internet_media_typefor use when sending XML. It also defines the types "application/xml" and "text/xml", which say only that the data is in XML, and nothing about its Semantics. Hope this helps!