Content deleted Content added
Tag: Reverted |
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
||
(10 intermediate revisions by 8 users not shown) | |||
Line 1:
{{short description|Method of providing unique elements and attributes in an XML document}}
'''XML namespaces''' are used for providing uniquely named [[Data element|elements]] and attributes in an [[XML]] document. They are defined in a [[World Wide Web Consortium|W3C recommendation]].<ref>{{cite web|last=Bray|first=Tim|title=Namespaces in XML 1.0|url=http://www.w3.org/TR/xml-names/|publisher=[[W3C]]|access-date=9 October 2010|author2=Dave Hollander |author3=Andrew Layman |author4=Richard Tobin |author5=Henry S. Thompson |date=December 2009}}</ref><ref name="timelinehistory">{{cite web |url=http://www.dblab.ntua.gr/~bikakis/
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 named '''id'''. References to the '''id''' element would therefore be ambiguous; placing them in different namespaces would remove the ambiguity.
Line 19:
For example, the following declaration maps the "xhtml:" prefix to the XHTML namespace:
<pre><nowiki>xmlns:xhtml="http://www.w3.org/
Any element or attribute whose name starts with the prefix "xhtml:" is considered to be in the XHTML namespace, if it or an ancestor has the above namespace declaration.
Line 25:
It is also possible to declare a default namespace. For example:
<pre><nowiki>xmlns="http://www.w3.org/
In this case, any element without a namespace prefix is considered to be in the XHTML namespace, if it or an ancestor has the above default namespace declaration.
Line 33:
Attributes are never subject to the default namespace. An attribute without an explicit namespace prefix is considered not to be in any namespace.
==
Different specifications have taken different approaches on how namespace information is presented to applications.
|