XML Namespace (xmlns) attribute

Source: Internet
Author: User

Http://www.w3school.com.cn/xml/xml_namespaces.aspXML Namespace (xmlns) attribute

The XML namespace attribute is placed in the start tag of the element and uses the following syntax:

xmlns:namespace-prefix= "NamespaceURI"

When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace.

Note: The address used to mark the namespace is not used by the parser to find information. Its only function is to give the namespace a unique name. However, many companies often use namespaces as pointers to the actual web pages that contain information about namespaces.

Please visit http://www.w3.org/TR/html4/.

Uniform Resource Identifier (Uniform Resource Identifier (URI))

A Uniform Resource identifier is a string of characters that can identify an Internet resource. The most common URI is the Uniform Resource Locator (URL) used to indicate the address of the Internet domain name. Another less common URI is a Uniform Resource name (URN). In our example, we only use URLs.

Default Namespaces Namespace

Defining a default namespace for an element allows us to omit the work of using prefixes in all child elements.

Please use the following syntax:

Xmlns= "NamespaceURI"

This XML document carries the information in a table:

xmlns="http://www.w3.org/TR/html4/">   <tr>   <td>Apples</td>   <td>Bananas</td>   </tr></table >

This XML document carries information about a piece of furniture:

xmlns="http://www.w3school.com.cn/furniture">   <name>african Coffee table</name>   <width>80</width>   <length>120 </length></table>
The actual application of namespaces

When you start using XSL, you will soon see the namespaces in the actual use. XSL style sheets are used to convert XML documents to other formats, such as HTML.

If you look closely at the following XSL document, you will see that most of the tags are HTML tags. Non-HTML tags have prefix xsl and are labeled by this namespace: "Http://www.w3.org/1999/XSL/Transform":

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match= "/" >

XML Namespace (xmlns) attribute

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.