XML namespace

XML Namespaces (English " XML namespaces " ) can be used to identify the vocabulary of an XML document clearly and to mix multiple XML languages ​​in a single document. Their function is to be compared with prefix in phone numbers.

For example describes the

element in XHTML a paragraph; in an XML language for a personnel database could represent

an element for a person. Namespaces allow to distinguish these elements clearly.

The namespace mechanism for XML data has been developed by the W3 Consortium and is since 8 December, 2009 the third edition both XML 1.0 and XML 1.1 before. The first version of the specification is dated 14 January 1999, about a year after the XML specification was adopted. For this reason, one finds, for example, in the Recommendation MathML 1.0 no namespace specified. The second version was published on 16 August 2006.

  • 4.1 colons in element names
  • 4.2 URLs as namespaces
  • 4.3 Document Type Definitions and Namespaces

Structure of XML namespaces

Namespaces are represented by URIs, so mostly by normal web addresses. It should be noted that the corresponding address does not need to exist. It can be defined arbitrarily. It is also important that must be in the namespace information is case- sensitive, even in the host portion, as well as any URL encoding, eg% C3% A4 instead of ä, respected.

If a URL is used as a namespace, but it usually makes sense to offer at this address additional information about the XML language, such as a document type definition (DTD) or an XML schema.

Use namespaces

For namespaces attribute xmlns is ( for eng. XML namespace ) is used:

   Rest of the HTML file ... The element and all its child elements, ie elements within ... belong here for namespace W3C XHTML namespace. Namespaces can also be nested:

   XHTML elements ...         MathML elements ...    < / math >    XHTML elements ... prefixes

In addition to the above-described method, there exists a prefix mechanism: Items can be set by a string that is separated by a colon from the element name, in any namespace. The prefix must have no relationship to the namespace, but first be " bound" to the namespace:

< html xmlns = " http://www.w3.org/1999/xhtml "        xmlns: m = " http://www.w3.org/1998/Math/MathML " >    XHTML elements ...         MathML elements ... with m: prefix       XHTML elements ... The prefix m m = "..." linked to the MathML namespace: In this example, in element by specifying xmlns. Then elements can by specifying

... are set in the corresponding namespace. In contrast, for example, without prefixes is to consider that child elements of an element with prefix does not automatically have the same name space. You must also be provided with a prefix:

< html xmlns = " http://www.w3.org/1999/xhtml "        xmlns: m = " http://www.w3.org/1998/Math/MathML " >    XHTML elements ...         Here is XHTML. Variable x: x < / m: i> < / span >       XHTML elements ... The actual element name, which is the part without the leading prefix and colon, called the local name of the element. The full or qualified name of the element ( QName short ) consists of the namespace URI and local name, the prefix can thus be chosen arbitrarily.

The prefix xmlns

Technically speaking, a construct of the type xmlns: m an attribute with a namespace prefix. There is therefore in the case of using an additional prefix namespace

Xmlns: xmlns = " http://www.w3.org/2000/xmlns/ " in the document. However, this is not explicitly specified, but assumed XML processing programs. As the following xml is firmly linked with the namespace given above also this prefix.

The prefix xml

XML elements can not begin with the string xml. It follows that also XML namespace prefixes must not start with xml. In fact, to a xml namespace for elements and attributes is bound, the reserved, the W3 Consortium for extensions of XML.

The URI for this namespace is the XML namespace. You need not be specified explicitly, but is inserted by the processing programs themselves.

Currently the following attributes exist with prefix xml (April 2010 ):

Attributes in XML are called associated nodes. You are not treated like normal child elements of an element. With namespaces, this means that attributes are not in the namespace of the element in which they are listed, but by default in the null namespace.

There are cases in which one wants to explicitly change. For example, links are included in SVG of the XLink language provides a set of attributes with which links can be described. In this case, the individual attributes must be prefixed with:

< svg xmlns = " http://www.w3.org/2000/svg "     xmlns: xlink = " http://www.w3.org/1999/xlink " >    link to Figure 2 There is no way to put it without prefix in a particular namespace for attributes.

Example

The following example elements or attributes from the XML languages ​​XHTML (blue), MathML (red), SVG ( green) and without namespace ( black) mixed. In particular, note that the attribute is xmlns itself in no namespace, its value is only colored to indicate which elements are affected by it.

< html xmlns = " http://www.w3.org/1999/xhtml "        xmlns: svg = " http://www.w3.org/2000/svg " >         example file with multiple namespaces </ title>    </ head>    <body>      <h1> A Math formula: < / h1 >      <math xmlns="http://www.w3.org/1998/Math/MathML">        <mi> x </ mi> <mo> = < / mo > <mn> 2 < / mn >      < / math >      <p> And a small picture this: </ p>      <svg:svg>        <svg:rect x="0" y="0" width="10" height="10" />        <svg:text>          <svg:tspan> A formula in the graph: </ svg: tspan >          <svg:tspan>            <math xmlns="http://www.w3.org/1998/Math/MathML">              <mi> y < / mi> <mo> = < / mo > <mn> 1 < / mn >            < / math >          </ svg: tspan >        </ svg: text >      </ svg: svg >      <p> SVG graphics can also be used without a prefix: </ p>      <svg xmlns="http://www.w3.org/2000/svg">        <circle svg:cx="10" svg:cy="10" svg:r="5" svg:fill="red" />      </ svg >    </ body> </ html> Namespace notation by James Clark </p> <p> Namespace prefixes can be chosen freely. In some contexts, such as when one sees only a small part of a more complex XML document, this arbitrariness can lead to misunderstandings. James Clark has therefore a different notation for element names introduced in his article XML namespaces that enjoys the documentation of XML data increasing popularity. </p> <p> A simple example could therefore look like this: </p> <p> < { http://www.w3.org/1999/xhtml } html>     < { } http://www.w3.org/2000/svg svg >     </ http://www.w3.org/2000/svg { } svg >   < / { http://www.w3.org/1999/xhtml } html> Elements in the text are then listed, for example as { http://www.w3.org/1999/xhtml } html. </p> <p> The URI of a namespace is thereby set for each element in braces before. Thus, the element is uniquely characterized by its namespace. This is the big advantage of this at first glance somewhat cumbersome method as it deems. </p> <p> Note that this notation is not a valid XML. It is used for illustration and documentation of namespaces. </p> <h2> Difficulties with XML namespaces </h2> <h3> Colons in element names </h3> <p> XML processing programs are classified into two groups: </p> <ul> <li>Programs, observe and handle the namespaces </li> <li>Programs that do not comply with the namespaces </li> </ul> <p> The main difference is the use of colons in element names. If the document is processed by a namespace - sensitive program, all colons must be interpreted as a separator of prefixes and element names - otherwise, the program generates an error. Programs that do not distinguish between namespaces, this Audit not. </p> <p> In XML, it is even possible to define elements that bear the colon already in the item name. But this is specifically not recommended. Files that use namespaces, but thus are well-formed XML documents. </p> <h3> URLs as namespaces </h3> <p> There is a regular issue in appropriate fora for now what you should deposit at the URL that is used as a namespace definition. The simple answer is that there must exist nothing. URLs, and general URIs are used as a definition, because they can provide some indication of who the "language" was developed, and because the relevant persons or organizations some at least symbolic control over a particular URL field (eg http://www.w3.org/ ... have for the W3 consortium ). </p> <h3> Document Type Definitions and Namespaces </h3> <p> XML languages ​​are still often defined with the so-called document type definitions. These DTDs, which date from the SGML time, were never intended to observe namespaces ( DTDs were developed in the 1980s ). It is very complicated and impossible in some cases, eg when any prefixes in XSLT or to establish a generally valid DTD for an XML language or document. </p> <p> An attempt to do this for XHTML, MathML and SVG to a file yet, can be found at the W3 Consortium. There, the possibility is created using definable in retrospect entities to determine new prefixes for each document. </p> </section> <section class="relLinks"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- memim 1 wide adaptive --> <ins class="adsbygoogle" style="display:block;clear:both;" data-ad-client="ca-pub-8545452838648870" data-ad-slot="6796476374" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <a href="/xml-schema-w3c.html">XML Schema (W3C)</a> <a href="/iso-639.html">ISO 639</a> <a href="/james-clark-programmer.html">James Clark (programmer)</a> <a href="/canonical-xml.html">Canonical XML</a> <a href="/document-object-model.html">Document Object Model</a> <a href="/w3c-geolocation-api.html">W3C Geolocation API</a> <a href="/internationalization-tag-set.html">Internationalization Tag Set</a> <a href="/rdf-schema.html">RDF-Schema</a> <a href="/semantic-interpretation-for-speech-recognition.html">Semantic Interpretation for Speech Recognition</a> <a href="/simple-knowledge-organization-system.html">Simple Knowledge Organization System</a> <a href="/synchronized-multimedia-integration-language.html">Synchronized Multimedia Integration Language</a> <a href="/speech-recognition-grammar-specification.html">Speech Recognition Grammar Specification</a> <a href="/speech-synthesis-markup-language.html">Speech Synthesis Markup Language</a> <a href="/sparql.html">SPARQL</a> <a href="/timed-text.html">Timed Text</a> <a href="/voicexml.html">VoiceXML</a> <a href="/web-services-description-language.html">Web Services Description Language</a> <a href="/xforms.html">XForms</a> <a href="/xinclude.html">XInclude</a> <a href="/xml-base.html">XML Base</a> <a href="/xml-encryption.html">XML-Encryption</a> <a href="/xml-events.html">XML Events</a> <a href="/xpointer.html">XPointer</a> <a href="/xproc.html">XProc</a> <a href="/call-control-extensible-markup-language.html">Call Control eXtensible Markup Language</a> <a href="/curie.html">CURIE</a> <a href="/html5.html">HTML5</a> <a href="/inkml.html">InkML</a> <a href="/rule-interchange-format.html">Rule Interchange Format</a> <a href="/smil-timesheets.html">SMIL Timesheets</a> <a href="/sxbl.html">SXBL</a> <a href="/extensible-forms-description-language.html">Extensible Forms Description Language</a> <a href="/xframes.html">XFrames</a> <a href="/xades.html">XAdES</a> <a href="/extensible-user-interface-protocol.html">Extensible User Interface Protocol</a> <a href="/w3c-markup-validation-service.html">W3C Markup Validation Service</a> <a href="/web-accessibility-initiative.html">Web Accessibility Initiative</a> </section> <div class="comments"> </div> <section> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-8545452838648870" data-ad-slot="9697283175"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </section> <span style="font-size:.5em">18901</span> <div class="share_buttons"> <div class="addthis_sharing_toolbox"></div> </div> </main> </div> </td></tr><tr><td id="footer"> <div class="aligner"> <footer class="mainHolder" style="text-align:center;"> <!--LiveInternet counter--><script type="text/javascript"><!-- document.write("<a href='http://www.liveinternet.ru/click' "+ "target=_blank rel=nofollow><img src='//counter.yadro.ru/hit?t18.5;r"+ escape(document.referrer)+((typeof(screen)=="undefined")?"": ";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth? screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+ ";"+Math.random()+ "' alt='' title='LiveInternet' "+ "border='0' width='88' height='31'><\/a>") //--></script><!--/LiveInternet--> <br /> memim.com 2024<br /> All rights reserved<br /> <span style='font-size:0.5em'>Page generated in 0.0031<br /></span> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5093bb6e1c1ddca0"></script> <script> function jr(ready){ if(window.jQuery){ //ready(); }else{ setTimeout(jr,100,ready); } } jr(function() { $(".imagesHolder img").each(function () { var i=$(this); console.log(i.attr('src')+' '+i.width()+' '+i.readyState); //$(this).remove(); }); }); </script> </footer> </div> </td></tr></table> <span style="font-size:.3em">de</span> </body> </html>