Content deleted Content added
m fixing double-redirect |
Should be a page in its own right |
||
Line 1:
An '''XML Namespace''' is a [[W3C]] standard for providing uniquely named elements and attributes in an [[XML]] instance. An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary is given a [[namespace]] then the ambiguity between identically named elements or attributes can be resolved.
All element names within a namespace must be unique.
A simple example would be to consider an XML instance that contained references to a customer and an ordered product. Both the customer element and the product element could have a child element "ID_number". References to the element ID_number would therefore be ambiguous unless the two identically named but semantically different elements were brought under namespaces that would differentiate them.
A namespace is declared using the reserved XML attribute <code>xmlns</code>, the value of which must be a [[Uniform Resource Identifier|URI]] (Uniform Resource Identifier) reference, e.g., <nowiki>xmlns="http://www.w3.org/1999/xhtml"</nowiki>. Note, however, that the URI is not actually read, it is simply treated by an XML parser as a string. For example, [http://www.w3.org/1999/xhtml http://www.w3.org/1999/xhtml] itself does not contain any code, it simply describes the [[xhtml]] namespace to human readers. Using a URI (such as <nowiki>"http://www.w3.org/1999/xhtml"</nowiki>) to identify a namespace, rather than a simple string (such as "xhtml"), reduces the possibility of different namespaces using duplicate identifiers.
The declaration can also include a short prefix with which elements and attributes can be identified, e.g., xmlns:xhtml="''http://www.w3.org/1999/xhtml''".
An XML namespace does not require that its vocabulary be defined, though it is fairly common practice to place either a [[DTD]] or an [[XML Schema]] defining the precise data structure at the ___location of the namespace's URI.
== External links ==
*[http://www.w3.org/TR/REC-xml-names/ W3C XML Namespace documentation]
*[http://www.w3schools.com/xml/xml_namespaces.asp XML Namespace Tutorial]
*[http://xml.coverpages.org/namespaces.html Cover Pages: Namespaces in XML]
[[Category:XML]]
[[Category:World Wide Web]]
|