In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The editor will share with you the example analysis of namespaces in XML. I hope you will get something after reading this article. Let's discuss it together.
The XML namespace provides a way to avoid element naming conflicts.
Naming conflict
Because the elements used in XML documents are not fixed, it is possible that two different XML documents use the same name to describe different types of elements. And this situation often leads to naming conflicts. Take a look at the following two examples
This XML document carries information about the fruit in the table element:
ApplesBananas
This XML document carries information about the table (furniture, inedible food) in the table element:
African Coffee Table80120
If the above two XML document fragments happen to be used together, there will be naming conflicts. Because both fragments contain elements, the definition and content of the two table elements are different.
Use prefixes to resolve naming conflicts
The following XML document carries information in the table element:
ApplesBananas
The following XML document carries information about the furniture table:
African Coffee Table80120
There is no element naming conflict now, because the two documents use different prefixes for their respective table elements, and the table elements are (and) in the two documents.
By using the prefix, we created two different table elements.
Use namespaces
The following XML document carries information in the table element:
ApplesBananas
The following XML document carries information about the furniture table:
African Coffee Table80120
In the above two examples, in addition to using prefixes, both table elements use the xmlns attribute to associate elements with different namespaces.
Namespace attribute
The namespace attribute is typically placed at the start tag of the element, and its syntax is as follows:
Xmlns:namespace-prefix= "namespace"
In the above example, the namespace defines an Internet address:
Xmlns:f= "http://www.w3schools.com/furniture"
The W3C naming convention declares that the namespace itself is a uniform resource identifier, Uniform Resource Identifier (URI).
When we use a namespace at the beginning tag of an element, all child elements of the element will be associated with the same namespace through a prefix.
Note: the network address used to identify the namespace is not called by the XML parser. The XML parser does not need to look up information from this network address. The network address is only used to give the namespace a unique name, so the network address can also be virtual. However, many companies often regard this network address as a real Web page. This address contains more detailed information about the current namespace.
Uniform resource identifier
A universal resource identifier (A Uniform Resource Identifier (URI)) is a string that identifies a network resource. The most common URI should be the uniform resource locator Uniform Resource Locator (URL). The address used by the URL to identify the network host. On the other hand, another less commonly used URI is the common resource name Universal Resource Name (URN). In our example, URLs is generally used.
Since the previous example uses the URL address to identify the namespace, we can be sure that the namespace is unique.
Default namespace
Defining a default XML namespace eliminates the need for prefixes in the opening tags of child elements. His grammar is as follows:
The following XML document contains information about the fruit in the table element:
ApplesBananas
The following XML document contains information about the furniture table:
African Coffee Table80120
Use namespaces
When you start using XSL, you will find that namespaces are used so frequently. XSL stylesheets are mainly used to convert XML documents into a format similar to HTML files.
If you look at the XSL document below, you will see that many of the tags are HTML tags. Those tags are not HTML tags, but prefixed XSL, which is identified by the namespace "http://www.w3.org/TR/xsl"" as the XSL prefix:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.