XML namespace: Difference between revisions

Content deleted Content added
Tags: Reverted Mobile edit Mobile web edit
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5
 
(2 intermediate revisions by 2 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/XMLSemanticWebW3CTimeline1.2.pdf |title=XML and Semantic Web W3C Standards Timeline (v.1.2) |access-date=2022-04-02 |archive-date=2022-12-29 |archive-url=https://web.archive.org/web/20221229130856/http://www.dblab.ntua.gr/~bikakis/XMLSemanticWebW3CTimeline1.2.pdf |url-status=dead }}</ref> An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary is given a [[namespace]], the ambiguity between identically named elements or attributes can be resolved.
 
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.
 
== enginncanerNamespace names ==
 
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 [[uniform resource locator|URL]] for the author's Web server. However, the namespace specification does not require nor suggest that the namespace URI be used to retrieve information; it is simply treated by an XML parser as a string. For example, the document at 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 probability of different namespaces using duplicate identifiers.