Content deleted Content added
Reverted good faith edits by 50.193.8.169 (talk): 'More than one vocabulary' uses the singular to refer to many. (TW) |
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
||
(29 intermediate revisions by 25 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 [[
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 9 ⟶ 10:
Although the term ''namespace URI'' is widespread, the W3C Recommendation refers to it as the ''namespace name''. The specification is not entirely prescriptive about the precise rules for namespace names (it does not explicitly say that parsers must reject documents where the namespace name is not a valid [[Uniform Resource Identifier]]), and many XML parsers allow any character string to be used. In version 1.1 of the recommendation, the namespace name becomes an [[Internationalized Resource Identifier]], which licenses the use of non-ASCII characters that in practice were already accepted by nearly all XML software. The term ''namespace URI'' persists, however, not only in popular usage, but also in many other specifications from W3C and elsewhere.
Following publication of the Namespaces recommendation, there was an intensive debate about how a relative URI should be handled, with some intensely arguing that it should simply be treated as a character string, and others arguing with conviction that it should be turned into an absolute URI by resolving it against the base URI of the document.<ref>{{cite web|title=News from the trenches|first=Leigh|last=Dodds|date=24 May 2000|url=
The use of URIs taking the form of URLs in the http scheme (such as ''http://www.w3.org/1999/xhtml'') is common, despite the absence of any formal relationship with the HTTP protocol. The Namespaces specification does not say what should happen if such a URL is dereferenced (that is, if software attempts to retrieve a document from this ___location). One convention adopted by some users is to place an [[RDDL]] document at the ___location.<ref>{{
== Namespace declaration ==
Line 27 ⟶ 28:
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.
If there is no default namespace declaration in scope, the namespace name has no value.<ref>{{cite web|url=https://www.w3.org/TR/REC-xml-names/#dt-qualname|title=Namespaces in XML 1.0 (Third Edition)|publisher=W3C|access-date=28 April 2017}}</ref> In that case, an element without an explicit namespace prefix is considered not to be in any namespace.
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.
Line 41 ⟶ 42:
* As attribute nodes named "xmlns" or "xmlns:xxx", exactly as the namespaces are written in the source XML document. This is the model presented by [[Document Object Model|DOM]].
* As namespace declarations: distinguished from attributes, but corresponding one-to-one with the relevant attributes in the source XML document. This is the model presented by [[JDOM]].
* As in-scope namespace bindings: in this model, the application is able to determine which namespaces are in scope for any given element, but is not able to determine which elements contain the actual declarations. This is the model used in [[XPath]], [[XSLT]], and [[XQuery]].
Line 59 ⟶ 58:
{{W3C standards}}
<!--Interwikies-->▼
{{DEFAULTSORT:Xml Namespace}}▼
<!--Categories-->
▲{{DEFAULTSORT:Xml Namespace}}
[[Category:XML]]
▲<!--Interwikies-->
[[ja:Extensible Markup Language#XML名前空間]]
|